ssh-copy-id命令 - 复制SSH公钥到远程主机

ID:15699 / 打印

ssh-copy-id命令来自英文词组ssh copy id,其功能是将本地生成的SSH公钥信息复制到远程主机。通常情况下,运维人员会先使用ssh-keygen命令生成SSH密钥对(公钥/私钥)文件,随后使用ssh-copy-id命令将公钥文件复制到远程主机上,这样操作后,再进行远程SSH访问时将无须进行账号密码验证,而是通过密钥方式登录。

语法格式:ssh-copy-id 参数 域名或IP地址

常用参数:

-f强制复制而不询问 -n仅测试,而不实际操作
-i设置公钥文件路径-p设置使用的端口号

参考示例

将SSH公钥文件复制到远程主机:

[root@linuxcool ~]# ssh-copy-id 192.168.10.10  The authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.  ECDSA key fingerprint is SHA256:212/FhZ+6JFs5psuMJx9+5alyW6QDzviE0miulDPiKk.  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.10.10's password: 此处输入远程主机管理员密码  Number of key(s) added: 1   Now try logging into the machine, with: "ssh '192.168.10.10'"  and check to make sure that only the key(s) you wanted were added. 
上一篇: ssh-add命令 - agent的高速缓存
下一篇: ssh-agent命令 - ssh密钥管理器

作者:admin @ 24资源网   2024-10-23

本站所有软件、源码、文章均有网友提供,如有侵权联系308410122@qq.com

与本文相关文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。