从另一台远程服务器通过SSH进入AWS ec2实例? [英] SSH into AWS ec2 instance from another remote server?
问题描述
我正在尝试从Digital Ocean上的远程服务器上的用户ssh进入AWS ec2实例.
I'm attempting to ssh into an AWS ec2 instance from a user on a remote server on Digital Ocean.
我将私钥上传到Digital Ocean上用户的.ssh文件夹中,在 .ssh
目录中创建了一个配置文件,以指向身份文件( .pem
包含私钥的文件),然后通过 ssh-keygen -y
生成一个公钥,并将其添加到ec2实例上用户的'.ssh/authorized_keys'文件中.
I uploaded the private key into the .ssh folder for the user on Digital Ocean, created a config file in in the .ssh
directory to point to the Identity File (.pem
file containing private key) then generated a public key via ssh-keygen -y
and added it to the '.ssh/authorized_keys' file for the user on the ec2 instance.
我的本地计算机以这种方式连接到ec2实例,而不会出现问题&我以为我可以以类似的方式在远程Digital Ocean实例上设置用户,但是在尝试连接时出现权限被拒绝(公钥)
错误.
My local machine connects to the ec2 instance in this way without issue & I assumed I could set up the user on the remote Digital Ocean instance in a similar manner but I am getting a Permission denied (publickey).
error when I attempt to connect.
详细错误输出:
debug1: Found key in /home/temp_user/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: .ssh/digital-ocean.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
temp_user
是Digital Ocean服务器上的新用户. digital-ocean.pem
是在AWS控制台中创建的私钥,通过该私钥生成了公钥并将其存储在aws实例上的新用户的 .ssh/authorized_keys
中.
temp_user
is the new user on the Digital Ocean server. digital-ocean.pem
is the private key created in AWS console from which the public key was generated and stored in .ssh/authorized_keys
for the new user on the aws instance.
为了测试,我暂时在本地和
To test, I temporarily uploaded the private key I use on my local and
ssh -i .ssh/local.pem< user> @<实例ID>
起作用.
我觉得这可能与aws实例上的新创建用户有关.
I feel like it may have to do with newly created user on the aws instance.
如何解决或解决此问题?
How can I troubleshoot or resolve this?
推荐答案
.ssh
目录应具有 755 权限,并由用户拥有. authorized_keys
文件应具有 644 权限,并由用户拥有.
The .ssh
directory should have 755 permissions and be owned by the user. The authorized_keys
file should have 644 permissions and be owned by the user.
这篇关于从另一台远程服务器通过SSH进入AWS ec2实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!