SSH-PING(1)

πŸ“¦
version 1.10 Β· 3 versions
, in arch rolling, debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– SSH-PING πŸ’–

okay bestie, welcome to the ssh-ping(1) page β€” it lives in the User Commands section of the manual, and it's genuinely the cutest little tool. it checks if a host is reachable, but it does it using your ssh_config, which is lowkey iconic of it. let's go πŸ¦‹


✨ NAME ✨

ssh-ping β€” check if host is reachable using ssh_config πŸ’…


✨ SYNOPSIS ✨

ssh-ping [OPTIONS] [user@]hostname

that's it. that's the whole vibe. options go first, then the host, and the [user@] part is optional because sometimes you just wanna let the config do its thing, periodt.


✨ DESCRIPTION ✨

check if host is reachable using ssh_config.

like. that's the whole job. it's a ping but make it ssh. no cap. πŸ”₯


✨ OPTIONS ✨

okay this is the part where I need you to lock in, because there are a LOT of these and every single one matters. no skimming, bestie 🫢

  • -4 β€” IPv4 only. old reliable energy.
  • -6 β€” IPv6 only. futuristic queen behavior.
  • -c count β€” stop after sending count request packets. so like, -c 1 means one and done, know your limits πŸ’…
  • -C β€” connect as soon as the host responds, and try reconnecting after a SSH session ends (e.g. rebooting). useful also for IDRAC, IPMI, ILO devices, Switches, etc... which don't have a full shell environment. CTRL+C stops reconnect attempts. this one is persistent and a little obsessive but we respect it πŸ’€
  • -E β€” exit immediately after first successful ping (can be used to trigger a follow up task like rsync). this is the "ok you're up, let's GO" flag fr fr.
  • -F configfile β€” specifies an alternative per-user configuration file. if a configuration file is given on the command line, the system-wide configuration file ( /etc/ssh/ssh_config ) will be ignored. the default for the per-user configuration file is ~/.ssh/config. so like, choose your own adventure, but know that picking one means the system one is out of the group chat 😭
  • -h β€” show this message. hi, hello, help is here πŸŽ€
  • -i interval β€” wait interval seconds between sending each request. the default is 1 second. patience is a virtue or whatever ✨
  • -l user β€” try login with user as username. the default is the current value of $USER. main character energy, literally.
  • -D β€” print timestamp (unix time + microseconds as in gettimeofday) before each line. nerdy and precise, we love her 🧚
  • -H β€” print timestamp (human readable) before each line. same but for people who don't read raw microseconds at brunch 🌸
  • -W timeout β€” time to wait for a response, in seconds. don't wait forever, bestie, it's not that serious πŸ’…
  • -p port β€” port to connect to on the remote host. this can be specified on a per-host basis in the configuration file. versatile icon πŸ‘‘
  • -q β€” quiet output. nothing is displayed except the summary lines at startup time and when finished. the strong silent type. 🀫
  • -n β€” no colors. (e.g. for black on white terminals). respectfully, monochrome moment πŸ–€
  • -v β€” verbose output. tell me EVERYTHING. give me the lore. πŸ—£οΈ
  • --version β€” show version information. who are you, where did you come from, what's your sign 🌈

✨ TAB_COMPLETIONS ✨

Ubuntu (and maybe other distros) already ship shell completions for ssh which can be used. so you don't even have to type the whole hostname like a peasant, slay πŸŽ€

  • Bash β€” complete -F _known_hosts ssh-ping
  • Zsh β€” compdef _ssh_hosts ssh-ping
  • Fish β€” complete -c ssh-ping -a "(__fish_print_hostnames)"

✨ ENVIRONMENT ✨

  • SSH_PING_NO_COLORS β€” if set, no colors are shown (like -n). it's giving "I said what I said" 🌈

✨ EXIT_CODES ✨

okay these are important because scripts LIVE and DIE by these. pay attention bestie πŸ‘‘

  • 0 β€” no requests lost. perfect. flawless. ate. ✨
  • 1 β€” more than 1 request lost. hmm. something's up. 😭
  • 2 β€” all requests lost. it's giving ghosted. absolutely nobody home. πŸ’€

✨ EXAMPLES ✨

here's the good stuff, copy these and go be great 🫢

ssh-ping -E hostname && echo "First successful ping. Starting rsync..."
ssh-ping -q -c 1 hostname >/dev/null && echo "Host is up!"
ssh-ping -q -c 1 hostname >/dev/null || echo "Host is down!"
SSH_PING_NO_COLORS=true ssh-ping -c 1 hostname

the && one is for when it's up, the || one is for when it's not, and the last one is for when you simply cannot with colors today. iconic scripting behavior, no notes πŸ’…


🌸 SEE ALSO 🌸

hmm, there's no SEE ALSO section in this one bestie, it's a short and sweet little page. we keep it exactly as it is β€” no invented references, that's the rule πŸŽ€


okay that's the whole page!! this one comes to you from the SSH-TOOLS collection, dated March 2024 πŸ’– go forth and ping your hosts, bestie. bye!! πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from