Here are two computers, one as the server (Test2) and the other as the client (Test1).
Test1:
- IP:20.0.0.11
Test2 :
- IP:20.0.0.12
First, we need to log in to the server (Test2) to set the login user permissions:
[root@ns2 ~]# vi /etc/ssh/sshd_config
......
AllowUsers root [email protected] ##只允许root和test2用户登录,但test2用户只能在主机IP为20.0.0.11上进行远程登录
......
[root@ns2 ~]# service sshd reload ##重新加载sshd
Then you can remotely log in to the server (Test2) on the client (Test1):
[root@ns1 home]# ssh [email protected]
......
re you sure you want to continue connecting (yes/no)? yes ##接受密钥
Warning: Permanently added '20.0.0.12' (ECDSA) to the list of known hosts.
[email protected]'s password: ##输入密码
[test2@ns2 ~]$ ##登录成功