Useful SSH commands for working with public/private keys

Below are a list of some useful commands for working with public/private keys on a server over ssh. All of these were pulled from the bitbucket documentation on setting up SSH for Git here.

Test what version of SSH you are running, if any:

$ ssh -v

List the contents of your ~/.ssh directory:

$ ls -a ~/.ssh

Generate a public/private key:

$ ssh-keygen

Test if an ssh-agent is running (for you to load your newly generated keys to):

$ ps -e | grep [s]sh-agent

If an agent is not running then start it manually:

$ ssh-agent /bin/bash

Load a new identity into the ssh-agent management program using the ssh-add command:

$ ssh-add ~/.ssh/id_rsa

List the keys that the agent is managing:

$ ssh-add -l

Show a key so you can copy and paste it on a LINUX server:

$ cat ~/.ssh/

Copy and paste a key on MAC OS:

$ pbcopy < ~/.ssh/

Leave a Reply

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

You are commenting using your 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