ssh - 由另一个用户向服务器添加ssh公钥

标签 ssh server ubuntu-14.04 public-key ubuntu-server

我有权ssh进入服务器,但我想在服务器上添加其他人的公钥,这样他也可以ssh进入服务器,我该怎么做...我尝试使用以下命令

<entered another users public key> | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

我得到这个错误
 w: No such file or directory

但是此命令对我来说不起作用...我该怎么办?

最佳答案

您可能需要echo:

echo "<entered another users public key>" \
    | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

关于ssh - 由另一个用户向服务器添加ssh公钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43336715/

相关文章:

ubuntu-14.04 - 如何从 react 器运行 state.sls

php - 为什么我的php -v版本与phpinfo()不同?

git - 在单个主机上使用多个 key 时,SSH 使用错误的 key

python - 在 python 中,如何获取本地服务器的日期和时间?

java - 如何在 ubuntu 上将 MySQL 连接到 NetBeans?

linux - 在 Mac 文本编辑器上打开 linux 机器中的文件

python - SSHClient.exec_command() 报告 "command not found"

ssh - .ppk 和 .pem 之间有什么区别? .pem 存储在亚马逊 ec2 集群中的哪里?

SSL 多级子域通配符

javascript - node.js - KOA 服务器 - 转发增强的 POST 请求