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 myserver
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
cat ~/.ssh/id_rsa.pub
ssh-copy-id [email protected]
ssh-keygen -p -f ~/.ssh/id_rsa
ssh-keygen -p -f ~/.ssh/id_rsa -N "new_passphrase"
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-add -l
ssh-add -D
ssh-add --apple-use-keychain ~/.ssh/id_rsa
echo "Host *\n UseKeychain yes\n AddKeysToAgent yes" >> ~/.ssh/config
ssh -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 50
sudo systemctl restart sshd
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
ssh-keygen -R remote-server.com