Skip to content

Instantly share code, notes, and snippets.

@Jarvl
Last active February 2, 2017 21:29
Show Gist options
  • Save Jarvl/b9ed1437a521644f2127af0f12d4b652 to your computer and use it in GitHub Desktop.
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
#!/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