linux系统配置ssh免密钥登录 **1. 执行 ssh-keygen -t rsa,一路回车,生成公钥和私钥** ``` -t type 指定要创建的密钥类型。 可以使用: rsa1:(SSH-1) rsa:(SSH-2) dsa:(SSH-2) ```  ``` 当前家目录中, /root/.ssh/id_rsa 是私钥 /root/.ssh/id_rsa.pub 是公钥 ``` **2. 将公钥文件传传给远程主机,输入远程主机对应的密码** ```bash [root@ _86_ ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.11.128 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.11.128 (192.168.11.128)' can't be established. ECDSA key fingerprint is SHA256:9VSEl5VrvJIV9v1UxBiHmBnKIkVBjfNqVGgsUrG4VeI. ECDSA key fingerprint is MD5:65:3a:b4:a5:14:05:21:dc:9c:fb:90:a3:dd:8e:00:fb. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.11.128's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.11.128'" and check to make sure that only the key(s) you wanted were added. ``` ``` 本质上该步骤是将公钥是放在远程主机192.168.11.128 的 /root/.ssh/authorized_keys 这个文件中 ``` **3. 此时远程登录主机ssh root@192.168.11.128,不会再输入密码**  **4. 基本思路** ``` ssh密钥对登录基本思路就是需要免密钥登录谁,就将公钥放在谁上面 位置是/root/.ssh/authorized_keys ``` 最后修改:2019 年 08 月 21 日 11 : 15 AM © 著作权归作者所有