High-performance SSH: Install HPN-SSH on OSX with keychain integration

· 251 words · 2 minute read

I use SSH for pretty much anything from VPN, server administration, database connections or iPython work on remote machines. When working from weird places and with weird internet connections SSH become painfully slow. I already use Mosh, but that also relies on ordinary SSH to initiate the connection.

Pittsburgh University has this OpenSSH-patch to remove some bottlenecks and make it 1000% faster (they claim).

Github-user ccosby made a Homebrew formula to install all the HPN-goodness via Homebrew. I just added Keychain support from the official openssh and added the latest patches and openssh-version. To use the hpn-ssh version, do the following:

[cc lang=“bash” width=“100%“tab_size=“4” lines=“40” noborder=“1” theme=“dawn”]
brew install https://raw.githubusercontent.com/manuelRiel/homebrew-ninja/master/hpn-ssh.rb –with-keychain-support –with-brewed-openssl
[/cc]

As stated, a launch-agent needs to be updated after installation. Replace /usr/bin/ssh-agent with /usr/local/bin/ssh-agent, as described here.

[cc lang=“bash” width=“100%“tab_size=“4” lines=“40” noborder=“1” theme=“dawn”]
$ launchctl stop org.openbsd.ssh-agent
$ launchctl unload -w /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
$ sudo vi /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
$ launchctl load -w -S Aqua /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
[/cc]

Now it’s best to restart, so then new ssh-agent becomes available.

You can compare the new speed with this command: (make sure you have the right binary by checking the version with -V.
[cc lang=“bash” width=“100%“tab_size=“4” lines=“40” noborder=“1” theme=“dawn”]
$ time /usr/bin/ssh server.example.com echo ‘hello’
[/cc]

And the new version
[cc lang=“bash” width=“100%“tab_size=“4” lines=“40” noborder=“1” theme=“dawn”]
$ ssh -V
OpenSSH_6.5p2-hpn14v4, OpenSSL 1.0.1g 7 Apr 2014
$ time ssh server.example.com echo ‘hello’
[/cc]

My speed improvement (avg of 20 runs) was about 1.4s vs. 3.3s. More than twice as fast.

(Image credit: Dragunov1981 via stockfreeimages.com)