SSH
SSH🔗
Config🔗
General🔗
1 2 3 4 5 6 7 8 |
|
Host
can be any identifier, even regular expressionsHostName
is the public hostname or IP address of your remote machineUser
is the username for this connectionIdentityFile
is the SSH private key for this connectionMatch
can be used to execute shell commands for extended pattern matching7
Forwarding🔗
forward private keys, so they can be used on the remote host
1 2 |
|
Proxy Command🔗
SSH-tunneling through intermediate host (jumphost). Outdated and vulnerable,6 use ProxyJump
instead5
1 2 |
|
ProxyJump🔗
Preferred way of connecting to host through intermedia host(s), which are called jump hosts or bastions (as they often are security-hardened entry points to networks)5
1 |
|
or configure
1 2 3 4 5 6 7 |
|
ControlMaster🔗
use an open connection for subsequent connections, so you don’t have to enter credentials again and it’s faster
1 2 3 4 5 6 |
|
Check status
1 |
|
Commands🔗
1 2 3 4 5 6 7 |
|
SSH-Add🔗
Add identities to the SSH agent. This allows to use keys without requiring the password every time they’re used. Consider limiting the time they’ll be held in the agent.
1 |
|
SSH-Keygen🔗
1 |
|
SOCKS proxy🔗
Tags: #tech/SSH/SOCKS
default port:3 1080
SSH config
1 2 3 4 5 6 |
|
then configure applications to use that proxy.4
For example in Firefox, usage of a SOCKS proxy can be selective for certain URLs, e.g. using the extension FoxyProxy.
Tools🔗
- assh (I haven’t tested it, didn’t have the need yet)
A transparent wrapper that adds support for regex, aliases, gateways, dynamic hostnames, graphviz, json output, yaml configuration, and more to SSH.
-
sshpass: provide password non-interactively. Security issue but haven’t found another way to enter a key pass phrase non-interactively (exposed e.g. in
ps
). Slightly better providing the password through a file ^sshpass1 2 3 4
sshpass -P"passphrase for key" -p <password> ssh ... # -P command prompt triggering password insertion (default 'assword:' ;) # or providing a password file, slightly more secure sshpass -f <file> ssh ...
Issues and Alternatives🔗
For flaky connections or if changing networks in something you regular do, consider mosh (mobile shell).
Remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes.
Mosh is a replacement for interactive SSH terminals. It’s more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.
Mosh is free software, available for GNU/Linux, BSD, macOS, Solaris, Android, Chrome, and iOS.
References🔗
- CVE-2024-6387: regression lead to vulnerability