Home > Uncategorized > An Illustrated Guide to SSH

An Illustrated Guide to SSH

Although the original posting is titled “An Illustrated Guide to SSH Agent Forwarding“, it covers pretty much all everyday uses of SSH (and then some).

Useful reading even if you already know SSH. Excellent memory refresher.

Also from the article “Where did I leave my (GPG) keys?” we learn an extremely useful bit of information. No need for manual transfer of private keys, means significant increase in security.

The good news is it is possible to use keys with OpenSSH too. The keys, once set up, will allow us to login to remote servers and transfer files without requiring us to type in our password. To create a set of OpenSSH keys we need to run:

ssh-keygen

We will be asked to provide an optional password to protect the key. A moment later we will have our key and now we need to transfer the key to the remote server. We can do that using the following command:

ssh-copy-id myuser@example.com

The above command will copy our key to the remote server example.com. When copying the key it’s important the user name we use is our username on the remote server, not on our local machine. For example, if I use the name jesse on my local machine, but my account on the server is jsmith I would use:

ssh-copy-id jsmith@remote-server.com

When we run ssh-copy-id we will be asked for our password on the remote machine. Once the key has been copied we can attempt to login to the remote server to make sure the key is in place:

ssh jsmith@remote-server.com

We should now be able to login without being prompted for a password. We should also be able to copy files over the secure connection without being prompted for a password. This makes scripting a lot easier as we can place lines like the following one in a script:

scp myfile.txt jsmith@remote-server.com:

Advertisements
Categories: Uncategorized Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: