ssh

SSH snippets

This is intended as a quick reference for SSH.

SSH snippets

List the ssh-keys currently available in the ssh-agent

ssh-add -l

Add the ssh-key to the ssh-agent

ssh-add -K ~/.ssh/id_rsa

To remove a key from the ssh-agent, the -d option can be used as the example below shows. This identifies the key to be removed.

ssh-add -d ~/.ssh/id_rsa

Removing all private keys from the ssh-agent can be achieved with the -D option as shown below.

ssh-add -D

Setup SSH tunnel

ssh -i ~/.ssh/id_rsa -L <LOCAL_PORT>:<DEST_SERVER>:<DEST_PORT> user@<JUMP_SERVER> cat -

SSH via tunnel

ssh -i ~/.ssh/id_rsa user@localhost -p <LOCAL_PORT>

SCP via tunnel

scp -i -i ~/.ssh/id_rsa file.txt user@localhost:/tmp/. -p <LOCAL_PORT>

References