//命令 ssh-keygen -t rsa <== 建立密钥对,-t代表类型,有RSA和DSA两种
//执行过程 [root@localhost ~]# ssh-keygen -t rsa <== 建立密钥对,-t代表类型,有RSA和DSA两种 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): <==密钥文件默认存放位置,按Enter即可 Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): <== 输入密钥锁码,或直接按 Enter 留空 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: SHA256:K1qy928tkk1FUuzQtlZK+poeS67vIgPvHw9lQ+KNuZ4 [email protected] The key's randomart image is: +---[RSA 2048]----+ | +. | | o * . | | . .O + | | . *. * | | S =+ | | . =... | | .oo =+o+ | | ==o+B*o. | | oo.=EXO. | +----[SHA256]-----+ ———————————————— 版权声明:本文为CSDN博主「独孤柯灵」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/u014721096/article/details/785530322、copy生成的key到远程主机
//命令 ssh-copy-id -i ~/.ssh/id_rsa.pub root@主机地址
//执行过程 [root@localhost ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '172.16.8.11 (172.16.8.11)' can't be established. ECDSA key fingerprint is SHA256:IpS8Vw0F/Yxece36yQ9KhoIuxHFjSi/Ect/WHGxw//k. ECDSA key fingerprint is MD5:03:85:10:9a:21:75:d6:f1:7a:6e:fd:a8:08:c5:ef:59. Are you sure you want to continue connecting (yes/no)? yes <== 是否继续连接,回答为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 [email protected]'s password: <==输入远程主机的密码 Number of key(s) added: 1 Now try logging into the machine, with: "ssh '[email protected]'" and check to make sure that only the key(s) you wanted were added.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)