大网数据广告活动
服务器运维问答

Port 22 blocked on AWS instance, can't SSH

· 52CE 我爱测

I enabled UFW on my ec2 instance and followed the following steps: abhi@my-ip-address:~$ sudo ufw default deny incoming abhi@my-ip-address:~$ sudo ufw allow 2200/tcp abhi@my-ip-address:~$ sudo ufw allow 80/tcp abhi@my-ip-address:…

问题原文

原帖链接 · Abhishek Ghosh · CC BY-SA 3.0

I enabled UFW on my ec2 instance and followed the following steps:

abhi@my-ip-address:~$ sudo ufw default deny incoming
abhi@my-ip-address:~$ sudo ufw allow 2200/tcp
abhi@my-ip-address:~$ sudo ufw allow 80/tcp
abhi@my-ip-address:~$ sudo ufw allow 123/udp

I did this in a hurry, and forgot to open port 22 on the server to enable SSH access. After doing some research, I found that I could another port number from my AWS console which I can then use to SSH into the server. So my Security Group tab looks something like this:


Then I used the following command to ssh into the my ec2 instance from local machine:

ssh -p 2200 -i photosite-app.pem ubuntu@my-ec2-ip

But get the following error message:

ssh: connect to host xx.xx.xx.xx port 2200: Connection refused


I am a newbie, and I realized my mistake only after it was late! Is there anyway, I could use a different port to ssh into my EC2 instance ? Any help is appreciated!

Thank you :)

EDIT:1 Tried to ssh with port 80 too:

~/.ssh » ssh -p 80 -i photosite-app.pem [email omitted]
ssh_exchange_identification: Connection closed by remote host

已采纳解答

原帖链接 · EEAA · CC BY-SA 3.0

Those other ports will only work if your sshd is listening on those ports, which it's not unless you explicitly configured it to do so.

You'll need to either scrap this instance and start over, or mount this server' root fs to another instance where you can fix the firewall rules.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。