【发布时间】:2020-09-29 10:51:17
【问题描述】:
如果我这样连接:
ssh -i "aws.pem" ubuntu@ec2-*-***-***-**.us-east-2.compute.amazonaws.com
一切正常,但如果我尝试为此设置配置:
Host sserv
Hostname ec2-*-***-***-**.us-east-2.compute.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/aws.pem
我无法连接...
这是我运行 ssh -v sserv 时得到的结果:
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/mrlalatg/.ssh/config
debug1: /home/mrlalatg/.ssh/config line 20: Applying options for sserv
debug1: /home/mrlalatg/.ssh/config line 30: Applying options for sserv
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to *.*.*.* [*.*.*.*] port 22.
debug1: connect to address *.*.*.* port 22: Connection timed out
ssh: connect to host *.*.*.* port 22: Connection timed out
也用 sudo 尝试过:
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
ssh: Could not resolve hostname sserv: Temporary failure in name resolution
注意:所有敏感信息都带有 *
【问题讨论】:
-
ssh 文件看起来不错。您确定您使用的是同一主机并且该手动 ssh 命令有效吗?
-
@Marcin 我确定,我复制粘贴了好几次...
-
@Marcin 添加了成功连接的截图
-
ssh 配置文件看起来不错。这也是我使用的。不明白为什么你会基于它超时。
-
@Marcin aws.pem 文件应该拥有哪些权限?我在上面使用了
chmod 400,因为这就是 aws 的建议。也许这就是问题所在?
标签: amazon-web-services amazon-ec2 ssh