与 .pub 文件的 SSH 连接 [英] SSH connection with .pub file

查看:66
本文介绍了与 .pub 文件的 SSH 连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从客户那里得到了 id_rsa.pub.我被告知要连接到它.我尝试使用 ssh-copy-id user@ec2-remoteserver.com

I am given with id_rsa.pub from client. And I was told to connect to it. I tried adding the key with ssh-copy-id user@ec2-remoteserver.com

但它给出了错误.权限被拒绝(公钥).

然后我想尝试联系

ssh -i /c/Users/kdash/Desktop/id_rsa.pub user@ec2-instance.com

现在显示错误

加载密钥/c/Users/kdash/Desktop/id_rsa.pub":格式无效

任何人都可以帮助我了解如何添加给定的 .pub 密钥文件并访问远程服务器.

Can anyone please help me understand how shall I add the given .pub key file and access to the remote server.

之前我已经使用 .pem 文件连接到服务器:

Earlier I had connected to servers with .pem files as such:

ssh -i /c/Users/kdash/Desktop/server.pem user@ec2-instance.com

我不清楚如何使用 .pub 文件.

I am not clear how .pub file can be used.

推荐答案

客户端应为您提供连接服务器的私钥.

Client should provide you the private key to connect to server.

我确信客户必须在他们的 ~/.ssh/authorized_keys

I am sure client must have added the public key in their ~/.ssh/authorized_keys

一旦客户端为您提供私钥文件,您就可以连接

Once client provide you the private-key file, then you can connect as

ssh -i user@ec2-instance.com

查看示例这里,远程机器正在~/中添加公钥.ssh/authorized_keys 然后用户可以使用私钥连接到它.

See example here, remote machine is adding public key in ~/.ssh/authorized_keys and then user can connect to it using private key.

所以我想,您需要私钥文件才能连接到远程 ssh 服务器.

So I guess, you need private key file to connect to remote ssh server.

远程机器不应该在~/.ssh/authorized_keys中添加私钥.

Remote machine should never add private key in ~/.ssh/authorized_keys.

这篇关于与 .pub 文件的 SSH 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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