If you use OpenSSH to connect to SSH servers on a regular basis, you may benefit from using an SSH configuration file. This will help you to shorten long commands:

ssh -p 2222 alykhan@student.cs.uwaterloo.ca

into an easily customizable shortcut:

ssh cs

This is accomplished by creating a text file located at ~/.ssh/config on your local machine with a few pieces of information and ensuring a specific set of permissions are applied to that file.

Setup Instructions

mkdir ~/.ssh/
chmod 700 ~/.ssh/
Host cs
    HostName student.cs.uwaterloo.ca
    User alykhan
    Port 2222

Note that this file must also meet specific permissions requirements as specified by the ssh_config man page (i.e. rw-------):

~/.ssh/config — Because of the potential for abuse, this file must have strict permissions: read/write for the user, and not accessible by others.

chmod 600 ~/.ssh/config


Congratulations! You may now connect to the SSH host via:

ssh cs

Feel free to add multiple Host entries to the config file, to have quick access to different HostNames via shortcuts like ssh website, ssh work, etc. Each of these entries may also have different User, Port, and other configuration values.