如何在另一台远程服务器上将SSH密钥用于Git?

问题描述

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

我先从本地计算机上使用ssh-copy-id [email protected],然后在远程计算机上使用sudo chmod -R 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys,将密钥添加到服务器。

现在是git。我正在尝试从远程服务器运行git clone [email protected]:user/some-repo.git获取以下日志:

Warning: Permanently added the RSA host key for IP address 'xx.xxx.xx.xx' to the list of kNown hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

如何使它工作?私钥是否也需要复制到此计算机上?我该怎么做呢?

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

解决方法

对于您而言,生成新的ssh密钥,使用ssh-keygen流并将add into your Git account作为新的访问密钥是正确的。