Last active
October 24, 2016 14:03
-
-
Save hiono/8264752 to your computer and use it in GitHub Desktop.
Add a vagrant ssh-config data to ".ssh/config" file. Require plugin: vagrant-global-status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SSH=$HOME/.ssh | |
[ ! -f $SSH/config ] && touch $SSH/config | |
[ -f $SSH/config ] && [ ! -f $SSH/config.orig ] && mv $SSH/config{,.orig} | |
rm -f $SSH/config.vagrant | |
touch $SSH/config.vagrant | |
for dir in $(vagrant global-status | grep $HOME) | |
do | |
pushd $dir > /dev/null | |
vagrant ssh-config --host $(basename $dir) >> $SSH/config.vagrant | |
popd > /dev/null | |
done | |
cat $SSH/config.orig $SSH/config.vagrant > $SSH/config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another approach within Vagrant directory :)
It's allowed to add some hostname aliases.
vagrant_ssh_config.sh host.alias.1 host.alias.2