SSH Keychain Access in Mac OSX Sierra

Prior to Sierra keys were persisted between logins – and with an update to ssh Keychain is no longer used by default. It can get frustrating to be prompted to enter your passphrase for a key after an upgrade and after each restart.

In your ~/.ssh/config file you will need the following lines:

Host *
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa

Change ~/.ssh/id_rsa to the filename of your private key and if you utilise multiple keys also add an IdentityFile line for each of them.

You also need to initially add the key to save the passphrase to Keychain for the first time using:
ssh-add -K ~/.ssh/id_rsa

SourceTree broke my SSH keys

Sourcetree is a great free git GUI client for Mac and Windows. A recent update (2.4) really broke my workflow however and it took me longer than it should have to figure out what the issue was.

It seems Atlassian are enforcing a behavioural naming convention for ssh keys, which seems somewhat crazy. Rather than go through and change all my own naming conventions to align with theirs I simply created some symlinks. Problem solved.

The format needed is: yourbitbucketusername-BitBucket.pub

Given the syntax for creating a symbolic link:
ln -s /path/to/original/ /path/to/link
You’ll need something along the lines of:
ln -s ~/.ssh/id_rsa.pub ~/.ssh/boolean-BitBucket.pub

Updating git in OSX

Recently there was a critical vulnerability in git announced affecting many git users including myself on OSX.

After downloading and installing the latest version of git and entering in Terminal
git −−version
I was presented with the incorrect version number. Checking where it had been installed with
which git
displayed the original
/usr/bin/git
instead of the newly installed version at
/usr/local/git/bin
To resolve this I added the correct path (to my bash profile)
export PATH="/usr/local/git/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:$PATH"
and now which git correctly returned the new path and bumped the version
git version 2.0.1

Hide or show hidden files quickly in OSX

How to setup some quick shortcuts to toggle visibility of hidden files in Finder

  • In Terminal type: sudo nano ~/.bash_profile
  • Append to the file the following: alias showFiles=’defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app’
  • In a new line type: alias hideFiles=’defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app’
  • Save the file
  • To make the aliases available in Terminal type: source ~/.bash_profile

Now you have two additional commands: showFiles and hideFiles to make things easier.