SSH
Setup⚑
Create SSH key⚑
ssh-keygen -t ed25519 -b 4096 -o -a 1000 -C "{username}" -f .ssh/{file}
Usage⚑
Connecting⚑
Force password login⚑
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no [host]
Jumping through a host⚑
ssh -J [host1] [host2]
SSH tunneling⚑
Make Remote Resources Accessible on Your Local System⚑
ssh -L local_port:remote_address:remote_port username@server.com
Config⚑
Multiple similar entries⚑
If you have multiple similar entries, they can share the common part:
Host X01
HostName X01.YYY.com
Host X02
HostName X02.YYY.com
...
Host X01 X02 ...
User my_username
Compression yes
Ciphers arcfour,blowfish-cbc
Protocol 2
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
IdentityFile ~/.ssh/YYY/id_rsa
Conflicting remote host keys on the same IP⚑
If you have different servers that use the same IP (at different times maybe), you'll have some annoying security alerts about their keys not matching with the previously stored one (since you only can save one of them). What you can do without risking the connection security is adding thes hosts like this in your ~/.ssh/config:
Host server1
Hostname x1.example.com
HostKeyAlias server1
CheckHostIP no
Port 22001
User karl
Host server2
Hostname x2.example.com
HostKeyAlias server2
CheckHostIP no
Port 22002
User karl
The important part is the HostKeyAlias line, that allows the SSH client to store the remote server public keys with the alias instead of with the unique shared IP address.
Dynamic IP host verification⚑
When you have a dynamic IP host, you might get Warning: the [whatever] host key for '[host]' differs from the key for the IP address
that is true, but also pretty annoying. If you'd rather just verify a host by its keys, instead of keys+IP, try with:
Host nickname
HostName example.dynamic.tld
CheckHostIP no
Debug⚑
Ctrl+s hangs the terminal⚑
From vimdoc:
Note: CTRL-S does not work on all terminals and might block
further input, use CTRL-Q to get going again.