💾 Archived View for henn.es › cheatsheet › ssh.gmi captured on 2023-11-04 at 11:28:17. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-07-10)

➡️ Next capture (2024-03-21)

-=-=-=-=-=-=-

hennes' SSH cheatsheet

Copy public key to authorized keys on remote server

cat id_rsa.pub | ssh USER@SERVER 'cat>> ~/.ssh/authorized_keys'

or alternatively

ssh-copy-id -i ~/.ssh/id_rsa.pub USER@SERVER

Port forwarding

ssh -NfL LOCAL_PORT:TARGET_IP_ON_REMOTE_HOST:TARGET_PORT_ON_REMOTE_HOST USER@SERVER

No -f to keep ssh process in foreground.

Example

Forward port to remote MySQL at example.com on local port 3307:

ssh -NfL 3307:127.0.0.1:3306 bob@example.com

Show fingerprint

This is useful to check the key length of a key.

ssh-keygen -lf ~/.ssh/id_rsa.pub