Skip to main content

SSH Cheat Sheet

· One min read

SSH key

Create SSH key

ssh-keygen -t ed25519 -C "example@example.com"

Copy public key to remote server

ssh-copy-id

SSH agent

Use SSH-agent in remote server

exec ssh-agent bash

Start SSH agent

eval $(ssh-agent -s)

Add key to agent

ssh-add ~/.ssh/[key file]

Enable agent forwarding in the local ssh config

ForwardAgent yes

Enable agent forwarding in the remote ssh server config

vi /etc/ssh/sshd_config

SSH server

Start and stop SSH server

systemctl status sshd
systemctl start sshd

jump host

ssh -J user@jumphost -R 8080:localhost:8080 user@hiddenhost
ssh -R 8080:hiddenhost:8080 user@jumphost