Skip to content

Instantly share code, notes, and snippets.

@jalex19100
Last active August 17, 2021 09:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jalex19100/7255957 to your computer and use it in GitHub Desktop.
Save jalex19100/7255957 to your computer and use it in GitHub Desktop.
User-Data script for AWS, to change the default SSHD port from 22 to 2222, or 443, the same port HTTPS uses.
#!/bin/bash -ex
perl -pi -e 's/^#?Port 22$/Port 2222/' /etc/ssh/sshd_config
service sshd restart || service ssh restart
@santosh
Copy link

santosh commented Aug 12, 2021

Connection times out.

@jalex19100
Copy link
Author

jalex19100 commented Aug 16, 2021

Don't know if you still need this today. AWS offers port forwarding and some other stuff, with EC2 instances, for free now. I haven't used this method of locking down SSH in a very long time.

@santosh
Copy link

santosh commented Aug 17, 2021

Not sure how much that relates to my situation here, but I wanted to change the SSH port which I initially use to connect to the EC2 instance.

Otherwise when I see the sshd logs, I see many people/bots lurking in. Just too many attempts to get in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment