首页 > 解决方案 > 如何在另一台远程服务器上使用我的 SSH 密钥进行 Git?

问题描述

我在让 Git 在新设置的远程服务器上工作时遇到问题。实际服务器本身我已关闭密码身份验证并使用密钥身份验证。服务器使用的密钥与我用于 git 的密钥相同。

我使用本地计算机将密钥添加到服务器ssh-copy-id user@4xx.xx.xx.xx,然后sudo chmod -R 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys在远程计算机上添加。

现在到 git。我正在尝试git clone git@github.com:user/some-repo.git从远程服务器运行并获取以下日志:

Warning: Permanently added the RSA host key for IP address 'xx.xxx.xx.xx' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

我怎样才能让它工作?私钥是否也需要复制到这台机器上?我该怎么做呢?

任何指针将不胜感激。谢谢!

标签: linuxsshssh-keys

解决方案


对于您的情况,生成新的 ssh 密钥、使用ssh-keygen流程并作为新的访问密钥添加到您的 Git 帐户中是正确的。


推荐阅读