Host Configuration

Quick Add:
Shortcut name for ssh my-server
IP address or domain name
Path to private key
Jump through another host
local_port remote_host:remote_port
remote_port local_host:local_port
Seconds between keepalive packets
Max keepalive failures before disconnect

Live Preview

# Add a host block to see your config here
# Use the form on the left, or try a Quick Add pattern

SSH Troubleshooter

Select the error message you are seeing and follow the step-by-step diagnostic checklist.

Understanding SSH Config Files

The SSH config file (~/.ssh/config) lets you define shortcuts and default settings for SSH connections. Instead of typing long commands like ssh -i ~/.ssh/mykey -p 2222 user@192.168.1.100, you can define a host block and simply type ssh myserver.

SSH Config File Location

The user-level SSH config file lives at ~/.ssh/config. The system-wide config is at /etc/ssh/ssh_config. User settings override system settings. If the file does not exist, create it:

mkdir -p ~/.ssh && chmod 700 ~/.ssh
touch ~/.ssh/config && chmod 600 ~/.ssh/config

Basic SSH Config Syntax

Each host block starts with Host followed by an alias. Indented lines below it set options for that host. You can use wildcards (*) to set defaults for all hosts.

Host myserver
    HostName 192.168.1.100
    User deploy
    Port 22
    IdentityFile ~/.ssh/id_ed25519

Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3

SSH Config File Example: Jump Host (ProxyJump)

A jump host (or bastion host) is an intermediary server you connect through to reach a private server. This is common in cloud environments where internal servers are not directly accessible from the internet.

Host bastion
    HostName bastion.example.com
    User admin
    IdentityFile ~/.ssh/bastion_key

Host internal-server
    HostName 10.0.1.50
    User deploy
    ProxyJump bastion
    IdentityFile ~/.ssh/internal_key

Now ssh internal-server automatically routes through the bastion host.

SSH Tunnel Command via Config

SSH tunnels forward ports between your local machine and a remote server. Use LocalForward to access a remote service locally, or RemoteForward to expose a local service remotely.

Host db-tunnel
    HostName db-server.example.com
    User admin
    LocalForward 5432 localhost:5432
    IdentityFile ~/.ssh/db_key

After running ssh db-tunnel, connect to localhost:5432 to reach the remote database.

SSH Proxy Jump Config for AWS

AWS environments often use a bastion host in a public subnet to reach EC2 instances in private subnets. Configure ProxyJump to automate this:

Host aws-bastion
    HostName 54.x.x.x
    User ec2-user
    IdentityFile ~/.ssh/aws-bastion.pem

Host aws-private
    HostName 10.0.2.15
    User ec2-user
    ProxyJump aws-bastion
    IdentityFile ~/.ssh/aws-private.pem

GitHub Deploy Key Setup

When you have multiple GitHub accounts or deploy keys, use SSH config to specify which key to use for each:

Host github-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_personal
    IdentitiesOnly yes

Host github-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_work
    IdentitiesOnly yes

Clone with: git clone git@github-personal:user/repo.git

Common SSH Permission Denied Fix

The "Permission denied (publickey)" error is the most common SSH issue. Typical causes:

  • Wrong key file -- ensure IdentityFile points to the correct private key
  • Key not added to remote ~/.ssh/authorized_keys
  • Wrong file permissions -- private key must be 600, .ssh directory must be 700
  • Wrong user -- verify the User field matches the remote account
  • SSH agent not running or key not loaded -- run ssh-add ~/.ssh/your_key

Key SSH Config Directives Reference

Directive Description Example
HostAlias for the connectionHost myserver
HostNameIP or domain of the serverHostName 10.0.1.5
UserUsername for the connectionUser deploy
PortSSH port (default 22)Port 2222
IdentityFilePath to private keyIdentityFile ~/.ssh/id_ed25519
ProxyJumpJump through another hostProxyJump bastion
ForwardAgentForward SSH agent to remoteForwardAgent yes
LocalForwardForward local port to remoteLocalForward 8080 localhost:80
RemoteForwardForward remote port to localRemoteForward 9090 localhost:3000
ServerAliveIntervalKeepalive interval in secondsServerAliveInterval 60
IdentitiesOnlyOnly use specified keysIdentitiesOnly yes
StrictHostKeyCheckingHost key verification policyStrictHostKeyChecking accept-new
CompressionEnable compressionCompression yes

Recommended VPS Providers for SSH Practice

If you need a remote server to practice SSH configuration, these providers offer affordable options:

  • DigitalOcean -- Droplets starting at $4/month. Simple UI, great docs, and fast SSD servers.
  • Linode (Akamai) -- Shared plans from $5/month. Reliable performance and global data centers.
  • Vultr -- Cloud compute from $2.50/month. Wide range of locations and OS options.

More Free Tools

All Tools .gitignore Generator Docker Compose Generator Config Converter