Here are some things that I wish someone had shared with me when I first started using SSH.
If your username is the same on your local machine
as it is on your remote, you can leave it out.
For example, if your local username and remote username
cyrus then you can just type
You can also run commands directly.
For example, you can type
ssh firstname.lastname@example.org pwd
and it will execute
pwd on your remote host.
By adjusting your SSH config, you can setup aliases for servers that you connect to often, significantly reducing boilerplate typing.
# ~/.ssh/config Host revtilt Hostname alpha.revtilt.com User deployer
$ ssh revtilt # is equivalent to the following $ ssh email@example.com
That alone was a game changer for me since it makes
logging into remote servers so much easier.
But, if I’m working on a remote host,
it’s likely that I’ll
rsync files or open another session.
You can speed up your remote commands by sharing the same connection.
Without the following configuration you negotiate
a separate SSH handshake for each session.
Host * Controlmaster auto Controlpath ~/.ssh/ssh-%r@%h:%p.sock
This creates a socket at the
is shared by
%r is the
%h is the
For a full listing of the options you can configure, go to:
$ man ssh_config
Create a tunnel from a remote machine’s port 80 to your local port 2001. This is useful for getting around firewalls.
$ ssh -N -L2001:localhost:80 remotemachine
You can also create a lightweight SOCKS5 Proxy. This is useful when you want to watch Netflix outside of the US or live coverage of the Olympics on the BBC.
$ ssh -D localport host