Skip to content

Instantly share code, notes, and snippets.

@angela-d
Created March 30, 2018 05:54
Show Gist options
  • Save angela-d/1313bfbb99ef779ceca538bcda259ac9 to your computer and use it in GitHub Desktop.
Save angela-d/1313bfbb99ef779ceca538bcda259ac9 to your computer and use it in GitHub Desktop.
SSH Terminal Alias Shortcuts

SSH Alias Shortcuts

Instead of logging into a remote server long-form, like ssh -i ~/.ssh/angela root@[host] -p22 ... make shortcuts!

ssh remoteserver

...and you're in.

Create a config file in ~/.ssh

nano ~/.ssh/config

Add the following; one for each host you want to add to your shortcut library

Host remoteserver
HostName [example.com or ip address of the remote server here]
Port 22
User root
Compression yes
IdentityFile ~/.ssh/angela

Host anotherremoteserver
HostName [example.com or ip address of the remote server here]
Port 3505
User sshusername
Compression yes
IdentityFile ~/.ssh/angela

Replace remoteserver for the alias you want to call anytime you need to head into the server with.

Replace ~/.ssh/angela with the path to your private ssh key for the server in question (it probably won't be the same key across the board, unless you explicitly configured your systems that way.)

To login to remoteserver, simply type:

ssh remoteserver

into the terminal. If your ssh key has a password, you'll be prompted for it; after that, you should be in the remote server.

Note: If your remote server doesn't support compression, simply set it to no, otherwise you'll have issues logging in with the shortcuts.

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