Skip to content

Instantly share code, notes, and snippets.

@jalex19100
Last active August 17, 2021 09:01
Show Gist options
  • Select an option

  • Save jalex19100/7255957 to your computer and use it in GitHub Desktop.

Select an option

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
@jalex19100

jalex19100 commented Aug 16, 2021 •

Copy link
Copy Markdown
Author

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

santosh commented Aug 17, 2021

Copy link
Copy Markdown

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