在CentOS上设置GitLab时,确保系统安全是非常重要的。以下是一些关键的安全设置步骤:
/etc/passwd
文件来检测并管理这些账户。adm
, lp
, sync
等,以减少系统受攻击的风险。/etc/login.defs
文件来强制执行这些要求。chattr
命令给 /etc/passwd
, /etc/shadow
, /etc/group
, 和 /etc/gshadow
文件加上不可更改属性。/etc/profile
文件中的 TMOUT
参数,设置root账户的自动注销时限。/etc/pam.d/su
文件,限制只有特定组的用户才能使用 su
命令切换为root。/etc/security/console.apps
下的相应程序的访问控制文件,防止普通用户执行关机、重启等敏感操作。使用firewalld:firewalld
是CentOS 7及更高版本的默认防火墙工具。可以通过以下命令来管理防火墙规则:
启动与停止firewalld:
sudo systemctl start firewalld
sudo systemctl stop firewalld
添加服务:允许特定服务通过,例如允许SSH服务:
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload
允许特定端口:开放端口8080:
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
修改外部URL:在GitLab配置文件 /etc/gitlab/gitlab.rb
中修改对外访问的域名或IP:
external_url 'http://your_server_ip:8080'
重新配置GitLab:修改配置文件后,使用以下命令重新配置GitLab:
sudo gitlab-ctl reconfigure
重启GitLab服务:重新配置后,重启GitLab服务以应用更改:
sudo gitlab-ctl restart
通过以上步骤,可以大大提高GitLab在CentOS上的安全性。确保定期更新GitLab和操作系统,以修补已知的安全漏洞。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:GitLab在CentOS上的安全设置