The ~/.ssh/config file is the single best way to stop that pain. It’s a per-user OpenSSH client configuration file (usually at /home/yourname/.ssh/config or ~/.ssh/config on macOS/Linux), and it lets you centralize all your connection logic so you rarely need flags anymore.
What it actually does (the good parts) 1 Host aliases / nicknames Turn ugly connection strings into one nice short name.
Host prod-db
HostName 10.88.12.45
User admin
Port 2222
IdentityFile ~/.ssh/prod_rsa
After that, you just type:
ssh prod-db
2 Common options you almost always want
User — default username
Port — non-22 ports
IdentityFile — which key to offer (and only that key if you pair it with IdentitiesOnly yes)
ProxyJump — jump hosts / bastions (the modern replacement for ProxyCommand)
Example with a bastion:
Host internal-server
HostName 192.168.77.22
User deploy
ProxyJump bastion.corp.example.com
3 Wildcards & patterns for groups of hosts Very powerful once you have 10+ machines with similar setup.
4 Security & hardening tricks (things people usually learn the hard way)
Host untrusted-host
StrictHostKeyChecking accept-new
UserKnownHostsFile /dev/null # only for throwaway/testing hosts!
Host *
# Good defaults everyone should consider
ServerAliveInterval 60
ServerAliveCountMax 3
Compression yes # sometimes helps a lot on slow links
ForwardAgent no # safer default nowadays
Quick example people actually use
# ~/.ssh/config
Host *
ServerAliveInterval 30
ServerAliveCountMax 5
AddKeysToAgent yes
UseKeychain yes # macOS only, keeps passphrase in keychain
Host jump
HostName jump.corp.example.com
User jumpuser
Host *.internal
ProxyJump jump
User app
IdentityFile ~/.ssh/internal_ed25519
Host laptop
HostName 192.168.1.88
User pi
Port 8822
Important gotchas / pro tips 1 Permissions must be 600: chmod 600 ~/.ssh/config OpenSSH will silently ignore the file if it’s too permissive — very common source of “why isn’t my config working?” pain.
我一直认为这句话经常导致软件设计师犯严重错误,因为它已经被应用到了不同的问题领域。这句话的完整版是“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.”
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
字面意思是97%优化是不值得也不应该做的,“过早”的那类优化是指这97%,关键点的优化,也就是剩下的3%仍是绝对必要的,虽然作者并没有直接说“这3%应该尽早做”,但某种程度上“we should not pass up our oppurtunities”大概已经包含了这层意思。作者并不反对优化,而且强调作关键优化的必要性。直白地说,他的意思是:不要浪费时间做那些根本不重要的优化。
Telnet is commonly used to check if a TCP connection to a specific port succeeds — essentially testing whether the port is open and reachable. Note that telnet itself is TCP-based, so it cannot test UDP sockets.
Quick background Telnet is the classic remote login client based on the TELNET protocol. It lets you run commands on a remote server as if you were sitting in front of it. You log in with username/password, but everything (including credentials) is sent in clear text — very insecure. Most modern Linux servers disable telnet and use SSH instead.
That said, curl can test HTTP services, and telnet can too (more on that below).
For UDP testing, use:
nc -u
nmap -sU
tcpdump
Application-level tools like dig for DNS
Common options
-4 Force IPv4
-6 Force IPv6
-8 Allow 8-bit data
-a Attempt automatic login (rarely used now)
-b<alias> Use alias for host
-e<char> Set escape character (default Ctrl+]) Example: telnet -e ^X host port
-l<user> Specify login user (for traditional telnet servers) Example: telnet -l root 192.168.1.10
-n<file> Log session to file (great for debugging)
In interactive mode After connecting, press Ctrl+] to enter telnet command mode. Useful commands:
quit Exit telnet
close Close current connection
status Show connection status
open host port Connect to new host/port
set localecho Enable local echo
toggle crlf Toggle CR/LF handling
Examples
Connect to a remote telnet service
telnet 192.168.120.206
(or by domain: telnet www.baidu.com)
If it fails:
Check IP/address
Is the host up?
Routing correct? (route)
Is telnet service running? (netstat -tlnp → look for TCP 23 LISTEN)
Firewall allowing port 23? (iptables -L)
Test TCP reachability (the 80% use case)
telnet 127.0.0.1 6379
Outcomes:
Connected → port open and TCP reachable
Connection refused → port not listening
Connection timed out → network/firewall issue
As a generic TCP client Telnet doesn’t care about application protocols — it just sends whatever you type over TCP. Perfect for quick testing of text-based protocols.
HTTP example:
telnet example.com 80
GET / HTTP/1.1
Host: example.com
(then hit Enter twice)
Redis example:
telnet 127.0.0.1 6379
PING
→ +PONG
Typical telnet service config (/etc/xinetd.d/telnet)
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}