Skip to content

Instantly share code, notes, and snippets.

@tusharf5
Created September 28, 2019 22:44
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save tusharf5/89a094de01321880fdf44bf1d4e4ea4c to your computer and use it in GitHub Desktop.
Save tusharf5/89a094de01321880fdf44bf1d4e4ea4c to your computer and use it in GitHub Desktop.
Change SSH Port on Amazon EC2 Instance

Change SSH Port on Amazon EC2 Instance

1. Launch and connect to EC2 instance running Amazon Linux 2.
2. Promote to root and edit /etc/ssh/sshd_config 
## sudo vi /etc/ssh/sshd_config
3. Edit line 17 (usually 17) #PORT 22. You'll need to un-comment the line and change the port to whatever you like. 
## PORT 9222
4. Save changes and exit
## :wq
5. Restart sshd 
## For Amazon Linux, RHEL 5, and SUSE Linux, use this command:
## sudo service sshd restart
## For Ubuntu, use this command:
## sudo service ssh restart
6. Add the new port in the INBOUND rules for your EC2 security group. Add a new TCP connection for 9222 for 0.0.0.0/0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment