Skip to content

Instantly share code, notes, and snippets.

@maesoser
Last active May 27, 2019 14:29
Show Gist options
  • Save maesoser/a30a66d9adcc600ae0faf810248cc377 to your computer and use it in GitHub Desktop.
Save maesoser/a30a66d9adcc600ae0faf810248cc377 to your computer and use it in GitHub Desktop.
Now it's recommended to use .ssh/config file instead of the old alias approach, but that does not mean that you've to loss the benefits of the aliases like autocompletion.
# copy this code to .bashrc
# This loop generates aliases for the hosts you've configured on ./ssh/config.
for x in $(grep '^Host' ~/.ssh/*config 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-); do
alias "$x"="ssh $x"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment