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, 2018 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. Mar 28, 2018 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, 2018 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. Mar 28, 2018 at 12:38

3 Answers 3


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

Use Custom not SSH Then change the ssh port to 2200


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!


This is not really an Ubuntu question, but the solution is to simply go to click the instance, go to Networking, and add your SSH port as "Custom" in the Firewall list.

Firewall whitelist SSH port for AWS Lightsail

Note that the web SSH client actually tries to connect only to port 22, so it will never work again once you change the port. This is a bit lame; Linode or other dedicated VPS providers allow you to remote into your machine via the equivalent of a terminal physically connected to it. That means you can completely mess up your networking or SSH configuration and you can still log in to fix things.

Not so with AWS Lightsail. I've search for this on the AWS forums, and the replies from AWS staff have been surprisingly unhelpful (example).

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.