我从客户端获得id_rsa.pub。我被告知要连接它。我尝试使用ssh-copy-id user@ec2-remoteserver.com
但它给出了错误。 Permission denied (publickey).
然后我想到尝试连接
ssh -i /c/Users/kdash/Desktop/id_rsa.pub user@ec2-instance.com
现在说错误
Load key "/c/Users/kdash/Desktop/id_rsa.pub": invalid format
任何人都可以帮助我了解如何添加给定的.pub密钥文件并访问远程服务器。
之前我曾使用.pem文件连接到服务器:
ssh -i /c/Users/kdash/Desktop/server.pem user@ec2-instance.com
我不清楚如何使用.pub文件。
答案 0 :(得分:1)
客户端应该为您提供连接服务器的私钥。
我确信客户必须在~/.ssh/authorized_keys
一旦客户端为您提供了私钥文件,您就可以连接为
ssh -i <private-key> user@ec2-instance.com
参见示例here,远程计算机正在~/.ssh/authorized_keys
中添加公钥,然后用户可以使用私钥连接到它。
所以我想,您需要私钥文件才能连接到远程ssh服务器。
远程计算机永远不应在
~/.ssh/authorized_keys
中添加私钥。