Last active
February 2, 2017 21:29
-
-
Save Jarvl/b9ed1437a521644f2127af0f12d4b652 to your computer and use it in GitHub Desktop.
Command line tool for switching ssh config and id_rsa files for git deployment with ssh keys
This file contains 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 | |
# Usage: sudo switch_ssh "file-prefix" | |
# Example: | |
# Files "my-project-id_rsa", "my-project-config" exist in ~/.ssh | |
# "sudo switch_ssh my-project" | |
# "my-project-id_rsa" is copied to "id_rsa", "my-project-config" is copied to "config" | |
cd ~/.ssh | |
if [[ $# -eq 0 ]] ; then | |
echo 'Input a file prefix' | |
exit 1 | |
fi | |
# Move the id_rsa file | |
cp id_rsa id_rsa-bak | |
cp $1-id_rsa id_rsa | |
# Move the config file | |
cp config config-bak | |
cp $1-config config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment