1 ssh服务常用配置
]# vim /etc/ssh/sshd_config
Port 2222
ListenAddress 192.168.4.52
:wq
]# systemctl restart sshd
]# netstat -utnlp | grep sshd
其他主机连接 ]# ssh -p 2222 root@192.168.4.52
2 黑白名单 (限制客户端连接时使用的用户及客户端地址)
白名单 : 仅允许使用列表里的用户连接
AllowUsers 用户列表
]# vim /etc/ssh/sshd_config
AllowUsers nb root@192.168.4.254
:wq
]# systemctl restart sshd
黑名单 : 仅不允许使用列表里的用户连接
DenyUsers 用户列表
]# vim /etc/ssh/sshd_config
#AllowUsers nb root@192.168.4.254
DenyUsers nb root@192.168.4.254
:wq
]# systemctl restart sshd
3 认证登陆方式 (默认2种都开启了)
密钥对认证登陆(公钥加密 私钥解密)
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
口令(用户密码) 65 PasswordAuthentication no/yes
4 配置密钥对认证登陆步骤
1 创建密钥对 ssh-keygen
2 把公钥传给目标主机ssh-copy-id root@192.168.4.52