A handy reference for ssh, ssh-keygen, and ssh-agent commands.
ssh -p 2222 [email protected]ssh [email protected] "ls -lah /var/www"ssh -v [email protected]ssh -i ~/.ssh/custom_key [email protected]Host myserver
    HostName remote-server.com
    User myuser
    Port 2222
    IdentityFile ~/.ssh/id_rsa
    ForwardAgent yesβ‘ Now you can simply run:
ssh myserverssh-keygen -t rsa -b 4096 -C "[email protected]"ssh-keygen -t ed25519 -C "[email protected]"cat ~/.ssh/id_rsa.pubssh-copy-id [email protected]ssh-keygen -p -f ~/.ssh/id_rsassh-keygen -p -f ~/.ssh/id_rsa -N "new_passphrase"ssh-keygen -p -m PEM -f ~/.ssh/id_rsaeval "$(ssh-agent -s)"ssh-add ~/.ssh/id_rsassh-add -lssh-add -Dssh-add --apple-use-keychain ~/.ssh/id_rsaecho "Host *\n  UseKeychain yes\n  AddKeysToAgent yes" >> ~/.ssh/configssh -L 8080:localhost:80 [email protected]Now, you can open http://localhost:8080 to access remote port 80.
ssh -R 9090:localhost:3000 [email protected]This makes local port 3000 available as remote-server.com:9090.
ssh -D 9090 [email protected]This sets up a SOCKS proxy on localhost:9090.
ssh -T [email protected]scp file.txt [email protected]:/remote/path/scp -r /local/dir [email protected]:/remote/path/rsync -avz -e ssh /local/dir [email protected]:/remote/path/journalctl -u sshd --no-pager | tail -n 50sudo systemctl restart sshdchmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pubssh-keygen -R remote-server.com