4-Linux的远程认证

增强ssh安全性

改变ssh的端口

1
2
3
4
5
6
7
cp /ect/ssh/sshd_onfig /etc/ssh/sshd_config.backup

vim /etc/ssh/sshd_config
...
Port 3333

service sshd restart

禁止root直接登录

1
2
3
4
5
vim /etc/ssh/sshd_config
...
PermissionRootLogin no
...
service sshd restart

只允许一部分用户登录

1
2
3
4
5
6
vim /etc/ssh/sshd_config
...
AllowUsers user1 user2
...

service sshd restart

使用密钥登录服务器

1
2
3
4
5
6
7
8
1. 首先在本地生成一个私钥和公钥。客户端
ssh-keygen-t rsa

2. 将客户端的公钥上传到服务器端
ssh-copy-id -p 33 linux@172.16.190.901

3. 登录
ssh -p 33 linux@172.111.111.111

禁止密码登录

1
2
3
4
5
6
vim /etc/ssh/sshd_config
...
PasswordAuthentication no
...

service sshd restart