Skip to content

Instantly share code, notes, and snippets.

@Sharique55
Last active October 3, 2025 16:43
Show Gist options
  • Select an option

  • Save Sharique55/7b461776a3bef9b9fb8e2d4fdff41511 to your computer and use it in GitHub Desktop.

Select an option

Save Sharique55/7b461776a3bef9b9fb8e2d4fdff41511 to your computer and use it in GitHub Desktop.
πŸ” Awesome SSH Mastery Cheat Sheet β€” Every Command, Tip, and Trick You’ll Ever Need!

πŸ” Ultimate SSH Mastery Cheat Sheet

A developer's one-stop shop for all things SSH β€” commands, configurations, flags, forwarding, tunneling, and more.

πŸ’‘ Pro Tip: Bookmark this page or clone it locally. It’s that useful.


πŸ”§ Table of Contents


πŸ› οΈ Basic SSH Commands

Description Syntax Example
Connect to server ssh [user]@[host] ssh user@192.168.1.10
Connect with port ssh -p [port] [user]@[host] ssh -p 2222 user@192.168.1.10
Run remote command ssh [user]@[host] "[command]" ssh user@host "uptime"
SSH with private key ssh -i [keyfile] [user]@[host] ssh -i ~/.ssh/id_rsa user@host
Disable host checking ⚠️ ssh -o StrictHostKeyChecking=no ... ssh -o StrictHostKeyChecking=no user@host

πŸ“ File Transfer (SCP & SFTP)

Description Syntax Example
Copy local β†’ remote file scp [file] [user]@[host]:[remote_path] scp notes.txt user@192.168.1.10:/home/user/
Copy remote β†’ local file scp [user]@[host]:[remote_path] [local_path] scp user@host:/tmp/logs.zip ./
Use port with SCP scp -P [port] [file] [user]@[host]:[path] scp -P 2222 file.txt user@host:/home/user/
Copy folder recursively scp -r [folder] [user]@[host]:[path] scp -r project/ user@host:/opt/
Start SFTP session sftp [user]@[host] sftp user@192.168.1.10

πŸ”‘ SSH Key Management

Description Syntax Example
Generate SSH key pair ssh-keygen -t rsa -b 4096 -f [filename] ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa
Add key to agent ssh-add [keyfile] ssh-add ~/.ssh/id_rsa
List keys in agent ssh-add -l ssh-add -l
Remove specific key ssh-add -d [keyfile] ssh-add -d ~/.ssh/id_rsa
Remove all keys from agent ssh-add -D ssh-add -D

βš™οΈ SSH Config File

Description Sample Config Snippet
SSH config file location ~/.ssh/config
Alias for server connection Host myserver\n HostName 192.168.1.10\n User user
Use custom key for a host IdentityFile ~/.ssh/custom_key
Reuse connection (multiplexing) ControlMaster auto\n ControlPath ~/.ssh/sockets/%r@%h-%p

🌐 Port Forwarding

Description Syntax Example
Local β†’ Remote port forwarding ssh -L [local]:[remote]:[port] [user]@[host] ssh -L 8080:localhost:80 user@host
Remote β†’ Local port forwarding ssh -R [remote]:[local]:[port] [user]@[host] ssh -R 9090:localhost:3000 user@host
Dynamic SOCKS proxy ssh -D [local_port] [user]@[host] ssh -D 1080 user@host

πŸ•³οΈ Tunneling & X11 Forwarding

Description Syntax Example
Enable X11 forwarding ssh -X [user]@[host] ssh -X user@host
Disable X11 forwarding ssh -o ForwardX11=no [user]@[host] ssh -o ForwardX11=no user@host

πŸš€ Advanced Usage

Description Syntax Example
Run SSH in background ssh -f [user]@[host] [command] ssh -f user@host "sleep 60"
Use specific protocol version ssh -2 [user]@[host] ssh -2 user@host
Use specific cipher ssh -c [cipher] [user]@[host] ssh -c aes256-cbc user@host

πŸ“‘ Session Management

Description Command Notes
Detach from SSH session Ctrl+Z Suspends the session temporarily
Reattach to session fg Resume background SSH
Terminate session exit Ends SSH connection

🐞 SSH Debugging

Description Syntax Example
Verbose output ssh -v [user]@[host] ssh -v user@host
More verbose ssh -vv [user]@[host] ssh -vv user@host
Most verbose ssh -vvv [user]@[host] ssh -vvv user@host

🧩 Proxying SSH Traffic

Description Syntax Example
Proxy via command ssh -o ProxyCommand="[cmd]" [user]@[host] ssh -o ProxyCommand="nc -X connect -x proxyhost:8080 %h %p" user@host
Proxy config in ssh config file ProxyCommand nc -X connect -x proxyhost:8080 %h %p Used inside ~/.ssh/config

πŸ”„ SSH Agent Forwarding

Description Syntax Example
Enable agent forwarding ssh -A [user]@[host] ssh -A user@host
Disable agent forwarding ssh -a [user]@[host] ssh -a user@host

🧰 SSH Utilities

Description Syntax Example
Copy SSH key to server ssh-copy-id [user]@[host] ssh-copy-id user@host
Scan SSH keys of host ssh-keyscan [host] ssh-keyscan github.com
Show SSH version ssh -V ssh -V

❀️ Like this Gist?

πŸ”– Star this gist to bookmark it!
πŸ‘₯ Follow @Sharique55 for more DevOps, Linux, Git, and Cloud goodness!
πŸ”„ Share it with your team, and spread the SSH mastery!


🏷️ Tags

#SSH #DevOps #Linux #RemoteAccess #SysAdmin #CloudEngineering #Networking #SSHTips #CheatSheet #Security


Stars Forks Followers GitHub SSH Cheat Sheet

@Sharique55
Copy link
Author

πŸ“‘ Whether you're a DevOps Engineer, Cloud Architect, Linux Enthusiast, Ethical Hacker, or Remote Developer β€” this ultimate SSH cheat sheet has everything you’ll ever need to master secure shell operations from the ground up.

πŸ” Covers: Basic SSH, Port Forwarding, SSH Config, Key Management, Tunnels, SFTP, Proxying, Debugging, Agent Forwarding, and more β€” in a clean tabular format with commands, syntax, and real-world examples.

⭐ Star it if you learned something.
πŸ” Fork it if you want to customize.
🧲 Share it if you want to help others!

πŸ”— Author: @Sharique55 β€” Follow for more ✨ DevOps, Linux, Git, and Cloud gems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment