This document is an SSH cheat sheet that provides essential commands for connecting to remote servers, managing SSH keys, configuring SSH client settings, transferring files, using SSH tunneling, executing commands remotely, and troubleshooting SSH connections. It includes specific command syntax and examples for each category. The cheat sheet serves as a quick reference for users working with SSH in various scenarios.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
5 views2 pages
SSH Cheat Sheet
This document is an SSH cheat sheet that provides essential commands for connecting to remote servers, managing SSH keys, configuring SSH client settings, transferring files, using SSH tunneling, executing commands remotely, and troubleshooting SSH connections. It includes specific command syntax and examples for each category. The cheat sheet serves as a quick reference for users working with SSH in various scenarios.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
SSH Cheat Sheet
Basic SSH Commands
● ssh user@host → Connect to a remote server ● ssh -p <port> user@host → Connect using a custom port ● ssh -i <keyfile> user@host → Connect using an SSH key ● ssh user@host -v → Connect with verbose output
Managing SSH Keys
● ssh-keygen -t rsa -b 4096 → Generate an RSA key pair ● ssh-copy-id user@host → Copy public key to remote server ● cat ~/.ssh/id_rsa.pub → Display your public key ● eval "$(ssh-agent -s)" → Start the SSH agent ● ssh-add ~/.ssh/id_rsa → Add private key to SSH agent
Host myserver HostName example.com User myuser Port 2222 IdentityFile ~/.ssh/mykey
● ● Connect using ssh myserver instead of full command
Transferring Files via SSH
● scp file user@host:/path/to/destination → Copy file to remote server ● scp user@host:/path/to/file ./ → Copy file from remote to local ● scp -r directory user@host:/destination/path → Copy directory recursively Using SSH Tunneling ● ssh -L local_port:destination_host:remote_port user@host → Forward local port ● ssh -R remote_port:local_host:local_port user@host → Forward remote port ● ssh -D <port> user@host → Create SOCKS proxy
Executing Commands via SSH
● ssh user@host 'command' → Run a command on remote server ● ssh user@host 'command1 && command2' → Run multiple commands ● ssh user@host 'bash -s' < script.sh → Run a local script on remote server
Disconnect & Troubleshooting
● ~. → Disconnect from SSH session ● ssh -v user@host → Debug SSH connection ● ss -tulpn | grep ssh → Check active SSH connections