将公钥发送到远程主机的命令
我记得有一个命令可以将公钥发送到我想要的远程主机。我想使用该功能将我的一个公钥发送到另一台主机。我怎样才能做到这一点?
I remember there is a command to send public key to the remote host that I want. I want to use that feature to send one of my public keys to the other host. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您正在寻找
ssh-copy-id
。此命令所做的只是创建.ssh
和.ssh/authorized_keys
并相应地设置它们的权限(如果它们不存在)。然后它将您的公钥附加到.ssh/authorized_keys
的末尾。You are looking for
ssh-copy-id
. All this command does is create.ssh
and.ssh/authorized_keys
and set their permissions appropriately if they don't exist. Then it appends your public key to the end of.ssh/authorized_keys
.您可能正在寻找此命令:
它将您的公钥附加到服务器授权的密钥上。
来源
You might be looking for this command:
It appends your public key to the servers authorized keys.
Source
如果您的服务器已设置为不接受基于密码的登录,您可能会收到
权限被拒绝(publickey)
错误。这是使用
netcat
发送密钥的另一种方法,因此您无需进行身份验证。它只能在本地网络上运行,但您可以使用端口转发在互联网上执行此操作。在服务器上:
在客户端上(将
HOSTNAME
替换为服务器的主机名或 IP):您可以将
55555
替换为您选择的开放端口。来源:通过 lan 从 linux 到 linux 聊天?
新手附录:我认为还没有人提到过这一点,但是如果出现
ERROR: failed to open ID file '/home/username/.pub': No such file
,则需要先生成密钥。 Ubuntu 帮助页面有关于生成 RSA 密钥的精彩指南。If your server is already set up to not accept password-based login, you might get a
Permission denied (publickey)
error.This is another method to send the key, using
netcat
, so you don't have to authenticate. It will only work over a local network, but you can use port forwarding to do this over the internet.On the server:
On the client (replace
HOSTNAME
with the hostname or IP of the server):You can replace
55555
with an open port of your choice.source: chat over lan from linux to linux?
Appendix for total newbies: I don't think anyone's mentioned this yet, but if you get
ERROR: failed to open ID file '/home/username/.pub': No such file
, you need to generate a key first. The Ubuntu help pages have a great guide on Generating RSA Keys.在其他答案中没有 ssh-copy-id 的示例,所以这里是(首先您需要生成密钥)
In other answers there's no example for ssh-copy-id so here it is(first you need to generate the key)