两台linux机器之间互连
连接的命令及查看 w
说明两个终端在连接 192.168.133.1 是windows 129是Alex2在连接
正确的写法
查看当前登录的 whoami
[root@alex-01 ~]# ssh root@192.168.129 完整的写法
[root@alex-01 ~]# ssh -p 22 root@192.168.133.129 指定端口的写法
设置秘钥
[root@alex-2 ~]# ssh-keygen 命令
Generating public/private rsa key pair. 回车
Enter file in which to save the key (/root/.ssh/id_rsa): 秘钥对放在那里
Enter passphrase (empty for no passphrase): 输入它的密码 密码设置空
Enter same passphrase again: 在回车
Your identification has been saved in /root/.ssh/id_rsa. 私钥
Your public key has been saved in /root/.ssh/id_rsa.pub. 公钥
The key fingerprint is:
68:0d:16:73:5a:56:3d:80:4d:ab:17:3c:68:a6:0f:27 root@alex-2
The key‘s randomart image is:
+--[ RSA 2048]----+
| o +=+o |
| B.o..o |
| + + = . |
| . B . o |
| E S . |
| . = . |
| . |
| |
| |
+-----------------+
[root@alex-2 ~]# ls /root/.ssh/ 查看公钥和私钥
authorized_keys id_rsa id_rsa.pub known_hosts
查看2的公钥
[root@alex-01 ~]# vi /root/.ssh/authorized_keys
添加进去
重启机器 了 看下selinux 有没启动 需要用getenforce 显示enforcing 证明selinux开启了 打开的
临时关闭 setenforce 0
[root@alex-01 ~]# getenforce 在看状态
Permissive
成功免秘钥
本文出自 “11325852” 博客,请务必保留此出处http://11335852.blog.51cto.com/11325852/1974566
原文:http://11335852.blog.51cto.com/11325852/1974566