一、修改ssh_d的配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| sudo vim /etc/ssh/sshd_config
Port 22 ListenAddress 0.0.0.0
PermitRootLogin yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys PasswordAuthentication no PermitEmptyPasswords no
AllowUsers zhangsan lisi@61.23.24.25
DenyUsers wangwu
|
生成密钥对
若禁用公钥登录并启用密码登录,则可以省去这一步
1
| ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
|

把~/.ssh/id_rsa
移到需要连接sshd的主机上
把~/.ssh/id_rsa.pub
移到被连接sshd的主机上并改名为authorized_keys
三、设置开机自启服务
1 2 3 4
| sudo systemctl enable ssh
sudo systemctl disable ssh
|
四、ssh常用命令
1 2 3 4 5 6 7 8 9 10
| ssh ip
ssh user@ip
sudo service sshd start
sudo service sshd stop
sudo service sshd status
|