SSH Cheatsheet
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
SSH Cheat Sheet
Section titled “SSH Cheat Sheet”5 Main SSH Commands
Section titled “5 Main SSH Commands”1. Connect to Remote Host
Section titled “1. Connect to Remote Host”ssh user@hostnamessh -p 2222 user@hostname- Establishes an interactive shell session on the remote host
-pspecifies a custom port (default is 22)
2. Generate SSH Keys
Section titled “2. Generate SSH Keys”ssh-keygen -t ed25519 -C "your_email@example.com"ssh-keygen -t rsa -b 4096 -C "your_email@example.com"- Creates public/private key pairs for passwordless authentication
ed25519is recommended for new keys (more secure, faster)
3. Copy SSH Keys to Remote Host
Section titled “3. Copy SSH Keys to Remote Host”ssh-copy-id user@hostname- Installs your public key on the remote host for passwordless login
- Alternative:
cat ~/.ssh/id_ed25519.pub | ssh user@hostname 'cat >> ~/.ssh/authorized_keys'
4. Copy Files (SCP)
Section titled “4. Copy Files (SCP)”# From remote to localscp user@hostname:/remote/path/file.txt ./
# From local to remotescp ./file.txt user@hostname:/remote/path/
# Recursive copy of directoriesscp -r ./localdir user@hostname:/remote/path/- Secure copy protocol for transferring files
5. Interactive File Transfer (SFTP)
Section titled “5. Interactive File Transfer (SFTP)”sftp user@hostname- Interactive file transfer session with commands like
get,put,ls,cd
SSH Port Forwarding
Section titled “SSH Port Forwarding”Local Port Forwarding (Access remote services locally)
Section titled “Local Port Forwarding (Access remote services locally)”ssh -L local_port:remote_host:remote_port user@ssh_hostExample: Access RDP through jump host
ssh -L 3389:10.10.202.4:3389 pfeddersheim- Local port
3389on your machine forwards to10.10.202.4:3389viapfeddersheim - Connect to
localhost:3389on your local machine
Dynamic Port Forwarding (SSH SOCKS proxy)
Section titled “Dynamic Port Forwarding (SSH SOCKS proxy)”ssh -D 1080 user@ssh_host- Creates a SOCKS proxy on local port
1080 - Useful for routing all traffic through the SSH host
Remote Port Forwarding (Expose local services remotely)
Section titled “Remote Port Forwarding (Expose local services remotely)”ssh -R remote_port:localhost:local_port user@ssh_host- Forwards
remote_porton the SSH host tolocal_porton your local machine
Useful SSH Options
Section titled “Useful SSH Options”| Flag | Description |
|---|---|
-N |
No remote command execution (used with port forwarding) |
-f |
Run in background after authentication |
-T |
Disable pseudo-terminal allocation |
-v |
Verbose mode (debugging) |
-vvv |
Maximum verbose mode |
-i identity_file |
Specify private key file |
-A |
Enable agent forwarding |
-X |
Enable X11 forwarding |
-L |
Local port forwarding |
-R |
Remote port forwarding |
-D |
Dynamic port forwarding (SOCKS proxy) |
Common SSH Configurations
Section titled “Common SSH Configurations”Edit or create ~/.ssh/config:
Host jump HostName pfeddersheim User your_username Port 22
Host target HostName 10.10.202.4 User your_username ProxyJump jump LocalForward 3389 10.10.202.4:3389Then connect with: ssh target