Skip to content

Instantly share code, notes, and snippets.

@delagoya
Created November 11, 2016 15:19
Show Gist options
  • Save delagoya/e01592f95b789127b277aa6de211d8bf to your computer and use it in GitHub Desktop.
Save delagoya/e01592f95b789127b277aa6de211d8bf to your computer and use it in GitHub Desktop.

Port 22 is BLOCKED! HALP!

The MCW auditorium wifi blocks the standard SSH network port, port 22. If you are to successfully connect to the EC2 instance from the MCW guest wifi, you will need to change the default port that the SSH service provides for connections. You will also need to allow network traffic to that port on the EC2 instance.

Step 1: the userdata script

The following Bash shell script will be used to add a port to the SSH service.

#!/bin/bash
echo 'Port 22' >> /etc/ssh/sshd_config
echo 'Port 443' >> /etc/ssh/sshd_config
service sshd restart

Copy and paste the above script into the userdata field in the web console launch.

user data script

Step 2: configuring the EC2 Security Group

Next you will need to add the standard HTTPS port, which is open on the guest wifi, in the set of ports that are allowed to connect to the EC2 instance

security group rules

Step 3: connect

After going through the rest of the EC2 launch wizard, you can connect to the instance by changing the port from 22 to 443. In PuTTY, you can view where to change here:

putty

For the SSH command line interface, such as the Terminal application on macOS, you can set the -p parameter like so:

# connect to Ubuntu, not a real IP
ssh -i mycert.pem -p 443 ubuntu@123.123.123.123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment