Bash - Create Multiple SSH key Aliases for BitBucket

: ' Check if you have ssh ' ssh -v : ' Show your current keys ' ls -a ~/.ssh : ' Create new SSH key (identity) - enter password when prompted ' ssh-keygen -f ~/.ssh/personalid -C "personalid" : ' Create an SSH Config file to alias accounts ' sudo vim ~/.ssh/config : ' Type in your aliases Host <alias> HostName <> IdentityFile ~/.ssh/<identity> ' Host workid HostName IdentityFile ~/.ssh/workid IdentitiesOnly yes Host personalid HostName IdentityFile ~/.ssh/personalid # Make sure to include `IdentitiesOnly` # if you are getting auth erorrs # and you know you ID is setup correctly. # It will hep bypass the default ID # as the first check. : ' Alternate config ' # Default GitHub user Host HostName PreferredAuthentications publickey IdentityFile ~/.ssh/personalid # Work user account Host HostName PreferredAuthentications publickey IdentityFile ~/.ssh/workid : ' Load Key into BitBucket `personalid` is what you named your ssh file in `~/.ssh`. `.pub` is the public key version you will paste the contents of, into bitbucket settings. ' # Show the contents that you can copy/paste cat ~/.ssh/ # MacOSX can use pbcopy to copy the contents to your clipboard pbcopy < ~/.ssh/ : ' Go to the BitBucket SSH settings, add a new key, and past the contents of the public key in there. URL:<username>/ssh-keys/ `<username>` is your username ' open<username>/ssh-keys/ : ' Usually your first clone, pull, fetch will require your password. So be sure to remember what that is. git clone git@<alias>:<team>/<project>.git ' git clone git@personalid:ATeam/Project.git

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.