SSH ping
SSH-based ping that measures interactive character echo latency and file transfer throughput. Pronounced "shipping".
A continuation and re-work of the original ssh-ping in Rust.
Installation
Cargo
sshping is published on crates.io, you can install it with (first having rust toolchain installed):
Homebrew (macOS/Linux)
sshping is also available on Homebrew/Linuxbrew, you can install it with:
Pre-built binaries
Pre-built binaries are available on the releases page. You can download the binary for your platform and put it in your $PATH.
From source
To install from source, you can clone the repository first:
# Or
# Then
Then build and install it with cargo:
Usage
<TARGET> [user@]host[:port]
)
)
)
Examples
Ping a host from ssh config with human-readable output and modern table style with rounded corners:
Ping a certain host with username and port, using _ as delimiter and a specific identity file:
| | | |
| | | |
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
| | | |
|
| | | |
Output results in JSON format:
{
}
Contributing
Contributions are welcome! Feel free to open an issue or a pull request. Anything from bug report to feature request to code contribution is appreciated.
Currently, there are a few things that can be added but haven't been yet. If you would like to help but don't know where to start, you can check this list below:
- Table style customization
- Unit tests
- Man page generation
- Shell autocompletion script generation
- Packaging for various platforms
- More SSH tests
- Better error handling
- Code optimization
FAQ
How to use public-private key pair for authentication?
Using public-private key pair is recommended. Provide the identity file (private key) path through the -i argument:
If your private key is encrypted with a passphrase, you can either:
- Provide it via the
-pflag:sshping user@host -i ~/.ssh/id_rsa -p "your-passphrase"(not recommended for security) - Let the tool prompt you interactively (recommended): When running in an interactive terminal, you'll be prompted to enter the passphrase securely
Authentication identity precedence is resolved per endpoint (target and each ProxyJump hop) in this order:
- SSH config
IdentityFilefrom the matchingHostblock for that endpoint - CLI
--identityfile - Fallback key discovery/default auth attempts (for example default keys under
~/.ssh)
This means proxy hops can use their own configured keys while the target can use a different key or fall back.
What about password authentication?
Password authentication is supported but not recommended. If no public key authentication is configured, the tool will:
- Use the password provided via
-pflag if available - Prompt you interactively for a password for the specific
user@hostendpoint when running in an interactive terminal (recommended over-pflag) - Fail if neither is available or in non-interactive environments (scripts, CI/CD)
Why isn't XXX functionality of SSH supported?
Many features like BindAddress are currently not supported due to the limitation of upstream libraries.
If they got implemented in the upstream libraries, they will be added to this project as well. Or you can open a pull request to add them yourself!
Why isn't all my identity file in SSH config being used?
If more than one identity file is given in the configuration file, only the first one will be used. This is an opinionated design choice to keep the implementation simple.
Shell autocompletion doesn't work
sshping supports two completion engines:
-
Runtime dynamic completion (recommended) with
clap_complete::CompleteEnv:This is recommended because it stays in sync with the installed binary and supports dynamic candidates (for example SSH config hosts).
-
Bash:
# Or source it directly in the current shell session: -
Zsh:
# Or source it directly in the current shell session: -
Fish:
echo "source (SSHPING_COMPLETE=fish sshping)" >> ~/.config/fish/config.fish # Or source it directly in the current shell session: source (SSHPING_COMPLETE=fish sshping) -
Elvish:
echo "eval (E:SSHPING_COMPLETE=elvish sshping | slurp)" >> ~/.elvish/rc.elv # Or source it directly in the current shell session: eval (E:SSHPING_COMPLETE=elvish sshping | slurp) -
PowerShell:
$env:SSHPING_COMPLETE = "powershell" echo "sshping | Out-String | Invoke-Expression" >> $PROFILE Remove-Item Env:\SSHPING_COMPLETE # Or source it directly in the current shell session: $env:SSHPING_COMPLETE = "powershell" sshping | Out-String | Invoke-Expression Remove-Item Env:\SSHPING_COMPLETE -
Xonsh:
Note: Xonsh support is currently not available in
clap_complete, but it can be added using the following workaround-
Install
fishshell and follow the fish instructions above to generate the completion script for fish shell. -
Install
xontrib-fish-completerxontrib to enable sourcing fish completion scripts in xonsh. -
Load
xontrib-fish-completerin your xonsh configuration:xontrib load fish_completer
-
-
-
Static completion scripts generated at build time by
build.rs(written undertarget/<profile>/completions).You can download the static files from releases page and source those manually if you prefer file-based setup.