如何将ssh密钥添加到远程服务器? [英] How to add a ssh key to remote server?

查看:43
本文介绍了如何将ssh密钥添加到远程服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的VPS中,运行 ssh-add -l <​​/code>并返回:代理没有身份.但是我已经运行 cat〜/.ssh/id_rsa.pub |ssh user @ hostname'cat>>以前的.ssh/authorized_keys

In my VPS, run ssh-add -l and it returns: The agent has no identities. but I have run cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys' previously

然后我运行 ssh-add〜/.ssh/authorized_keys 它返回 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//警告:未受保护的私钥文件!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"/home/deployer/.ssh/authorized_keys"的权限0644太开放了.建议他人不能访问您的私钥文件.此私钥将被忽略.

ssh git@github.com 仍获得报告权限被拒绝(公钥).

推荐答案

当前投票最多的答案显然是错误的,因为它无法理解问题.OP正在询问如何授权远程服务器上的密钥,而不是如何向本地ssh-agent添加密钥.

The currently most up voted answer is plainly wrong as it fails to understand the question. OP is asking how to authorize a key on a remote server, not how to add a key to your local ssh-agent.

要将密钥添加到远程服务器,请使用 ssh-copy-id 命令:

To add a key to a remote server use the ssh-copy-id command from your local PC:

ssh-copy-id -i path/to/key.pub username@remoteHost

这会将位于 path/to/key.pub 的具有正确权限的公钥添加到 remoteHost 上的服务器,并使用 username 作为登录名.请注意,这似乎还需要在公共密钥(此示例中为 path/to/key 文件)旁边的私有密钥.

This adds the public key located at path/to/key.pub with the correct permission to the server at remoteHost using username as login name. Note that this also seems to require the private key next to the public key (the path/to/key file in this example).

这篇关于如何将ssh密钥添加到远程服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆