Network & Security
Updated for 2026

SSH Client & Configuration Cheatsheet

Secure remote shell connections, SSH key generation, port forwarding, config files, and file transfer tunnels.

Target Version Compatibility

Interactive Skill Mastery

Mark commands as learned to build your customized reference tracker. Retained locally in this browser.

Level:Novice
Command Mastery Progress0 of 18 Mastered (0%)

Connection Basics

ssh user@hostname
BeginnerBasics
Initiate a basic secure remote terminal connection to a server.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -i ~/.ssh/id_ed25519 user@hostname
BeginnerBasics
Connect utilizing a specific private key file for high-security key-based authentication.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -i ~/.ssh/id_ed25519 user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -J jump_host_user@jump_host user@target_host
BeginnerBasics
Connect to a target host inside a private network by proxying through an SSH jump host server.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -J jump_host_user@jump_host user@target_host

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -t user@host "tail -f /var/log/nginx/access.log"
IntermediateDebugging
Request and allocate a remote pseudo-terminal to execute interactive console streams directly.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -t user@host "tail -f /var/log/nginx/access.log"

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.

Key Management

ssh-keygen -t ed25519 -C "admin@example.com"
BeginnerBasics
Generate a modern, highly secure Ed25519 SSH cryptographic key pair.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh-keygen -t ed25519 -C "admin@example.com"

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@hostname
BeginnerBasics
Append your public key to the remote server's authorized_keys file safely.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh-copy-id -i ~/.ssh/id_ed25519.pub user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh-add -l
BeginnerBasics
List all private cryptographic keys currently registered and loaded in the active local SSH Agent session.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh-add -l

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh-keygen -p -f ~/.ssh/id_ed25519
BeginnerBasics
Modify or append a strong security passphrase onto an existing private SSH key without recreating it.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh-keygen -p -f ~/.ssh/id_ed25519

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.

Tunnels & Port Forwarding

ssh -L 8080:localhost:3000 user@hostname
BeginnerBasics
Local Port Forwarding: Tunnel local port 8080 through SSH to remote port 3000.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -L 8080:localhost:3000 user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -R 9000:localhost:5000 user@hostname
BeginnerBasics
Remote Port Forwarding: Expose your local port 5000 on the remote server's port 9000.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -R 9000:localhost:5000 user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -D 1080 user@hostname
BeginnerBasics
Dynamic Port Forwarding: Establish a local SOCKS proxy tunnel over port 1080.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -D 1080 user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.

Secure Copy & Sync

scp localfile.txt user@hostname:/var/www/html/
BeginnerBasics
Securely copy a local file to a specified remote server directory.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

scp localfile.txt user@hostname:/var/www/html/

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
scp -r user@hostname:/var/log ./server_logs
IntermediateDebugging
Download an entire remote folder recursively to your local workspace.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

scp -r user@hostname:/var/log ./server_logs

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
rsync -avz -e ssh ./data/ user@host:/backup/
BeginnerBasics
Synchronize local files with a remote host over an SSH tunnel, preserving timestamps and permissions.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

rsync -avz -e ssh ./data/ user@host:/backup/

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.

Config & Security

cat ~/.ssh/config
AdvancedSecurity
View/Edit client SSH config files to save host definitions and skip typing flags.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

cat ~/.ssh/config

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -o ServerAliveInterval=60 user@hostname
AdvancedSecurity
Send a background keep-alive packet every 60 seconds to prevent connection timeouts.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -o ServerAliveInterval=60 user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -o StrictHostKeyChecking=no user@host
AdvancedSecurity
Override host-key validation warnings (useful in non-interactive CI/CD deployment runner environments).

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -o StrictHostKeyChecking=no user@host

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.
ssh -v -p 2222 user@hostname
AdvancedSecurity
Activate verbose diagnostic logs to trace handshake, key exchange, and config file negotiations on custom ports.

When to Use

When establishing secure encrypted terminal shell sessions, forwarding remote ports, or transferring files to remote hosting servers.

Common Mistakes

Hardcoding active credentials or exposing vulnerable server ports without enforcing key-based login or SSH configs.

Shortcut / Pro-Tip

Configure standard connection shortcuts inside your `~/.ssh/config` file to avoid typing complex flags.

Example

ssh -v -p 2222 user@hostname

Output Example

Console / Terminal
Secure SSH session established with remote system. Terminal ready.

SSH Best Practices

1Disable Password Authentication completely

Always set PasswordAuthentication no in your remote server's sshd_config. Enforce key-based cryptographic logins exclusively to eliminate brute-force attack vectors.

2Leverage Modern Ed25519 Keys

Avoid legacy RSA keys. Generate modern, highly secure, fast-performing cryptographic key pairs using ssh-keygen -t ed25519.

3Utilize Client SSH Configurations

Build a streamlined connection index in ~/.ssh/config to map Hostnames, Users, and Key paths, avoiding typing complex terminal flags.

4Enforce Key Permissions rigorously

Maintain strict file permissions. Set chmod 600 ~/.ssh/id_ed25519 to prevent SSH clients from rejecting keys due to loose world-readable privileges.

5Implement Keep-Alives

Configure ServerAliveInterval 60 in your client config. This sends periodic background packets to keep sessions open, eliminating silent connection drops.

Common SSH Errors & Solutions

Error

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

Solution

The remote server's host key changed (likely due to OS reinstall). Clear the stale footprint using: ssh-keygen -f ~/.ssh/known_hosts -R <hostname>.

Error

Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

Solution

The server rejected your key. Ensure your public key is added to remote ~/.ssh/authorized_keys, file permissions are correct, and ssh-agent has loaded your private key.

Error

ssh: connect to host port 22: Connection timed out

Solution

A network firewall is blocking traffic, or the server is down. Check host connectivity, verify the target port, and ensure sshd is running on the host.

Error

Permissions 0644 for private key are too open

Solution

The SSH client blocks connection attempts with open private keys. Repair permissions instantly by running: chmod 600 ~/.ssh/id_ed25519.

Error

ssh-agent not loading keys automatically

Solution

Make sure ssh-agent is initialized on your shell, or add your key definitions to the ssh-agent explicitly using: ssh-add ~/.ssh/id_ed25519.

Common SSH Interview Questions

Q1How does SSH key-based authentication work?

It utilizes asymmetric cryptography. The client generates a private and public key pair. The public key is stored in the remote server's authorized_keys file. During handshake, the server sends a challenge encrypted with the public key, which the client decrypts with its private key to prove identity without transmitting active secrets.

Q2Explain the difference between Local Port Forwarding (-L) and Remote Port Forwarding (-R).

Local Port Forwarding (-L local_port:remote_host:remote_port) tunnels traffic from a local machine port to a remote server. Remote Port Forwarding (-R remote_port:local_host:local_port) does the reverse, exposing a local service port out onto a public remote server port.

Q3What is the purpose of SSH multiplexing (ControlMaster)?

Multiplexing allows multiple concurrent SSH sessions or scp operations to share a single, pre-established TCP connection. This eliminates TCP handshake and key exchange overhead, making subsequent connections almost instantaneous.

Q4How can you securely connect to a server inside a private subnet using a jump host?

By using the ProxyJump flag (-J). For instance: 'ssh -J proxy_user@proxy_host target_user@target_host'. This creates an automated encrypted SSH tunnel through the jump host, directly routing connection requests securely.

Q5What is the role of the known_hosts file in SSH?

The known_hosts file is stored locally (~/.ssh/known_hosts) and registers the unique public keys of all remote servers you connect to. On subsequent handshakes, the client verifies the host key matches the stored footprint, protecting you against Man-in-the-Middle hijacking.