我在AWS中有两个实例。其中一个在公共子网(堡垒)中,第二个在私有子网中。
它们都是用相同的密钥对(.pem文件)启动的。
这就是我如何连接到堡垒的方式:
ssh -i secret.pem ec2-user@public-ip工作很好,我加入了。
现在,我想在私有子网中对实例进行ssh。谷歌说我应该转发代理:
ssh -A ubuntu@private-ip但不幸的是,我得到了一个错误:
Permission denied (publickey).有人能解释一下我做错了什么,以及如何处理私人实例吗?(平安及保安团体均正常)
发布于 2021-08-08 11:42:10
我就是这样做的:
在您自己的膝上型计算机中,创建(或编辑现有文件)~/..ssh/config,并添加以下内容:
Host [host or ip of the bastion server]
User ec2-user
IdentityFile ~/.ssh/pem_file_required_to_connect_to_bastion
Host [host or ip of the bastion server]
User ec2-user
IdentityFile ~/.ssh/pem_file_required_to_connect_to_server
ProxyCommand ssh ec2-user@CHOSEN_HOST -W %h:%p用您为堡垒服务器配置的同一主机替换CHOSEN_HOST。
示例:
cat ~/.ssh/config
Host 3.126.138.136
User ec2-user
IdentityFile ~/.ssh/itaig.pem
Host 172.31.22.212
User ec2-user
IdentityFile ~/.ssh/itaig.pem
ProxyCommand ssh ec2-user@3.126.138.136 -W %h:%p
~/.ssh at 02:40:57 PM
❯
ssh 172.31.22.212
Last login: Sun Aug 8 11:40:41 2021 from ip-172-31-29-253.eu-central-1.compute.internal
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[ec2-user@ip-172-31-22-212 ~]$https://serverfault.com/questions/1073881
复制相似问题