Linux安全基础配置及其他相关

Linux安全基础配置及其他相关

1.sshfs 通过ssh远程挂载目录到本地
安装sshfs软件包
yum install fuse-sshfs -y
配置挂载目录
sudo sshfs -o allow_other,default_permissions root@10.0.1.82:/data/ /mnt/sshfiles/
检查挂载结果
df -hT /mnt/sshfiles/
卸载挂载目录
sudo fusermount -u /mnt/sshfiles
参考:
https://phenix3443.github.io/notebook/ssh/sshfs.html

2.将root账户设置为仅限控制台登录
vim /etc/ssh/sshd_config
systemctl restart sshd.service d_config
结果就是ssh远程登录root不成功

3.TCP Wrappers对远程主机进行访问控制
vim /etc/hosts.deny
添加 sshd: ALL
表示拒绝所有主机通过sshd服务访问
vim /etc/hosts.deny
添加 sshd: ALL
表示允许所有主机通过sshd服务访问,如果hosts.deny和hosts.allow都配置了sshd: ALL 那么允许优先

4.通过控制特定用户账号登录限制ssh访问
vim /etc/ssh/sshd_config
添加下面信息
AllowUsers cntf
DenyUsers shit
重启sshd服务
systemctl restart sshd.service
表示拒绝用户shit通过ssh登录,允许cntf通过ssh登录
如果都不是上面两个用户登录的话,同样是被拒绝登录

5.仅使用protocol2协议和设置禁用空密码登录,设置密码重试次数
vim /etc/ssh/sshd_config

Protocol 2
ClientAliveInteral 600
ClientAliveCountmax 0
PermitEmptyPasswords no
PasswordAuthentication yes
MaxAuthTries 6
systemctl restart sshd.service

6.配置ssh身份验证
vim /etc/ssh/sshd_config
添加或者取消注释下面的内容
PubkeyAuthentication yes
PasswordAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

配置生成公钥和私钥
ssh-keygen -t rsa
ssh-copy-id root@10.0.1.2
迷茫的人生,需要不断努力,才能看清远方模糊的志向!
原文地址:https://www.cnblogs.com/autopwn/p/14792766.html