Multiple .ssh Profiles
Recently I encountered an issue where my Macbook Pro has been "green screening" - as in the entire screen turns green and flashes like it's trying to give me a seizure.
It was an odd issue that cropped up at an odd time, but one of the things I did to combat the issue was make sure my Time Machine updates were up-to-date so I could erase my disk and install the OS clean. Although this did not resolve the green screening, it did give me another idea.
See, when I setup this laptop I setup a separate "work" account from my regular user account for focus reasons. As a result, since I didn't want to do a full Time Machine restore during the work day between Apple Genius appts, I had a situation where my Time Machine backups had two users in there. The biggest restriction I had here is the two different pairs of RSA keys I generated: one for all my personal stuff (my user) and another for all my work stuff.
The solution I came up with was to basically symlink ~/.ssh
to one directory or the other. The basics:
$ mkdir -p ssh/{quintessence,work}
$ cp -r /Volumes/{{VOLUME NAME}}/Backups.backupdb/{{MACBOOK NAME}}\ Pro/Latest/Macintosh\ HD/Users/work/.ssh/* ssh/work/
$ cp -r /Volumes/{{VOLUME NAME}}/Backups.backupdb/{{MACBOOK NAME}}\ Pro/Latest/Macintosh\ HD/Users/quintessence/.ssh/* ssh/quintessence/
Now to directly link to my work account:
$ ln -s ~/ssh/work ~/.ssh
Quick note: in both of my .ssh
directories I had subdirectories with other keys/info that I needed. If you don't have subdirectories, you don't need the -r
.
If you would like to use a script, take a look at macops ssh
. I wrote it just for this use case, but I imagine it'll grow over time.