Skip to content

Instantly share code, notes, and snippets.

@jlongman
Last active July 10, 2017 16:30
Show Gist options
  • Save jlongman/5cfffee8a7a6f06f1ffdb28afdbe7f4d to your computer and use it in GitHub Desktop.
Save jlongman/5cfffee8a7a6f06f1ffdb28afdbe7f4d to your computer and use it in GitHub Desktop.
Output .ssh/config HostName entries
#!/bin/sh
# Output the HostName value from ~/.ssh/config
# SOURCE this, don't execute (e.g. "source ssh_host.sh" or ". ssh_host.sh")
# echos $@ if no HostName present
# Useful for shell substitution
# e.g. iperf -u -p 6970 -c $(ssh_host dev_backend)
ssh_host() {
ssh -G "$@" | grep -i '^hostname ' | awk '{print $2}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment