在CentOS-02 虚拟机里面连接 CentOS-01
在CentOS-01 中查看负载,看哪个设备在连接着
#w
在CentOS-02 中连接 CentOS-01
#ssh 192.168.136.128
在CentOS-01 中查看负载
#w
这个时候就发现多了个 192.168.136.129 也就是CentOS-02
严格的写法远程连接 ssh username@ip
查看下当前用户
#whoami
#ssh root@192.168.136.128
指定端口的严格写法 ssh -p 22 username@ip
#ssh -p 22 root@192.168.136.128
两个机器间秘钥认证
在CentOS-02 上生成密钥对
#ssh-keygen
回车
回车
回车
复制CentOS-02 上面生成的公钥
#ls /root/.ssh/
#cat root/.ssh/id_rsa.pub
在CentOS-01 中打开 /root/.ssh/authorized_keys
#vi /root/.ssh/authorized_keys
复制CentOS-02 上面生成的公钥粘贴到这个里面,按ESC 输入 :wq 保存退出
在CentOS-01 中查看防火墙状态
#getenforce
Enforcing 证明selinux是打开的
临时关闭selinux
#setenforce 0
再查看下状态,就发现变了
#getenforce
两个机器间秘钥登录
在CentOS-02 中连接CentOS-01
#ssh -p 22 root@192.168.136.128
不需要输入任何东西,直接就进来了。