复制[root@kht151 zoneinfo]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
SHA256:GNZUKGru5TwlLi59ToR+uObeq/CBPjeQL7acjaVNqxw root@kht151
The key's randomart image is:
+---[RSA 2048]----+
| .o. |
| .o. |
| .o.. |
| oo o |
| +. o S |
| oo.oo . |
| E=*=oo |
| +=%OB* |
| .X%@*+o |
+----[SHA256]-----+
[root@kht151 ~]# for i in kht151 kht152;do ssh-copy-id -i .ssh/id_rsa.pub $i;done
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub"
The authenticity of host 'kht151 (192.168.2.151)' can't be established.
ECDSA key fingerprint is SHA256:ETrT47WngKUihzAZMulgqLliS2td/knN7JOB0lOQEYE.
ECDSA key fingerprint is MD5:77:80:22:a8:ff:e7:71:09:56:a2:7a:90:fb:f3:93:aa.
Are you sure you want to continue connecting (yes/no)? yes
二、ubuntu系统
复制root@master:/mnt/vos-d0gnoqpd# 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:
SHA256:jG7HKt9a4rKtLv66H/p5xfKENUKm4W09tnyoIrVadzE root@master
The key's randomart image is:
+---[RSA 3072]----+
| |
| . o |
| . * . |
| o +o* |
| ..BE= |
| ..o.Bo. |
| .o.=*=. |
| oo=BoB. |
| .*@OO*.. |
+----[SHA256]-----+
#指定为ubuntu用户
root@master:/mnt/vos-d0gnoqpd# ssh-copy-id ubuntu@192.168.100.11
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out an y 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
Warning: Permanently added '192.168.100.11' (ECDSA) to the list of known hosts.
ubuntu@192.168.100.11's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'ubuntu@192.168.100.11'"
and check to make sure that only the key(s) you wanted were added.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫