当前位置: 首页 > Linux

linux机器互相登录

时间:2023-04-07 00:02:30 Linux

在CentOS-02虚拟机中连接CentOS-01查看CentOS-01中的负载,查看连接的是哪个设备#w在CentOS-02中连接CentOS-01#ssh192.168.136.128在CentOS中查看-01#w中的负载,此时发现多了一个192.168.136.129,这是CentOS-02的严格写法远程连接sshusername@ip查看当前用户#w??hoami#sshroot@192.168.136.128指定端口的严格写法ssh-p22username@ip#ssh-p22root@192.168.136.128两台机器之间的秘钥认证在CentOS-02上生成密钥对#ssh-keygenEnterEnterEnter复制上面生成的公钥CentOS-02Key#ls/root/.ssh/#catroot/.ssh/id_rsa.pub在CentOS-01打开/root/.ssh/authorized_keys#vi/root/.ssh/authorized_keys复制把上面在CentOS-02上生成的公钥粘贴进去,按ESC输入:wq保存退出。在CentOS-01中查看防火墙状态#getenforceEnforcing证明selinux是开启的,暂时关闭selinux#setenforce0再查看状态,会发现#getenforce是两台机器之间的秘密KeyloginConnectCentOS-01#CentOS-02中ssh-p22root@192.168.136.128,什么都不用输入,直接进来就可以了。