这里是两台电脑 ,一台作为服务器(Test2) 一台作为客户机(Test1)。
Test1:
- IP:20.0.0.11
Test2:
- IP:20.0.0.12
首先我们需要登入服务器(Test2)设置登录用户权限:
[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
然后就可以在客户机(Test1)上进行远程登录服务器(Test2):
[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 ~]$ ##登录成功