2

I have changed ssh port in lightsail server in /etc/ssh/sshd_config file to 2200, I have enabled firewall to accept connections on port 2200. But when I am trying to connect through my local machine using command,

ssh -i key.pem ubuntu@13.xxx.x.109 -p 2200

It is showing me an error "ssh: connect to host 13.xxx.x.109 port 2200: Connection refused". Can you help me out why it's connection is being refused?

  • Has the key already been shared to the lightsail server, could you use it to login successfully on the default port? Also, do you need to use the absolute path to the key file? – Arronical Mar 28 '18 at 9:51
  • yeah i was able to connect to lightsail server through port 22 using private key but when I changed port settings and enabled firewall settings on lightsail server its showing me the error shown above. Currently I am using ubuntu as local machine. – Bhanu Sankhyan Mar 28 '18 at 12:07
  • 1
    Did you change the port that the ssh server is listening on and restart the ssh server? This is normally done in the /etc/ssh/sshd_config file on the server you're trying to ssh into. – Arronical Mar 28 '18 at 12:24
  • 1
    yes I did changed the port to 2200 and i also checked with nmap, its showing "host is up" on 2200 port of lightsail ubntu server,that means 2200 port is open on server but it's not listening on port 2200 when i am connecting through ssh using my local machine. – Bhanu Sankhyan Mar 28 '18 at 12:38
2

You need to turn on the port of the lightsail manage console.

Use Custom not SSH Then change the ssh port to 2200

1

I am using aws LightSail and I ended up doing the following:

  • add to lightsail management console: Application = Custom, Protocol = TCP, Port = 2200

  • edit the port in sshd_config in /etc/ssh/ folder to 2200.

  • restart sshd by sudo service restart sshd

  • add the rule to firewall sudo ufw allow 2200/tcp

  • enable the firewall sudo ufw enable

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.