Command Book

SSH

KEYGEN

Create a SSH new key

ssh-keygen -t rsa

AGENT

Start agent

eval "$(ssh-agent -s)"

List agent identities

ssh-add -l

Add SSH private key to agent

ssh-add -K ~/.ssh/id_rsa

Remove all identities from agent

ssh-add -D

load all keys from keychain

get the agent to load all keys whose passphrases are stored on Keychain

ssh-add -A 

Kill agent

ssh-agent -k

COPY

Copy public key to remote server

ssh-copy-id -i ~/.ssh/id_rsa user@host

Add your public key to authorized_keys

cat your_public_key.pub >> .ssh/authorized_keys

Debug SSH commands

ssh -v {commands}

CONNECT

ssh -i ~/.ssh/mykey

Steps to create & authenticate a key

1. Create a key with: ssh-keygen -t rsa
1. Add a passphrase
1. Copy the public key to the remote resource
1. Add the key to the local agent: ssh-add -K /path/to/key
1. Add passphrase here (this is the first and last time)
1. Add the host entry to ~/.ssh/config
1. Test with ssh {Host from config}

Tunneling

ssh -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
Last updated on Sat, Apr 17, 2021
Published on Tue, Oct 17, 2017