ssh config
SSH (~/.ssh/config), Parameters, SSH command
Syntax
Host <alias> HostName <hostname> User <username> Port <port> IdentityFile <key_path>
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
Host |
, * | Host myserver |
Common |
HostName |
IP | HostName 192.168.1.100 |
Common |
User |
User deploy |
Common | |
Port |
SSH | Port 2222 |
Common |
IdentityFile |
IdentityFile ~/.ssh/work_key |
Common | |
ProxyJump |
ProxyJump bastion |
Advanced |
Examples
Host prod HostName production.example.com User deploy Port 2222 IdentityFile ~/.ssh/prod_key
ssh prod
GitHub
Host github-work HostName github.com User git IdentityFile ~/.ssh/work_key Host github-personal HostName github.com User git IdentityFile ~/.ssh/personal_key
git clone git@github-work:org/repo.git
Host 10.0.0.* User admin IdentityFile ~/.ssh/internal_key StrictHostKeyChecking no
Host * ServerAliveInterval 60 ServerAliveCountMax 3
60,
Common Errors
Bad configuration option,
(chmod 600 ~/.ssh/config), Host
Tips
- config, Host, Host *
- ssh -F /dev/null user@host
- 600,