Post-Image

Use Alfred and SSH-Keys for blazing fast password-less SSH login on OSX

Posted on

You wish you were that fast to securely login via ssh right?

Actually if you’re also using a mac you can do that too. First off you need to install Alfred and buy the Powerpack so you can use Workflows with Alfred.

http://www.alfredapp.com/powerpack/

Also we need brew so we can install ssh-copy-id.

brew install ssh-copy-id

Still following?

Now we need to install the ssh workflow for Alfred. This already enables us to connect to the hosts we want to but we still want a passwordless login, so keep on following this post.

As seen in this post from Digitalocean, it’s really easy to set up ssh keys to enable the passwordless login.

First we need to generate a ssh-key with the ssh-keygen command.

ssh-keygen -t rsa

After generating the keys with the default options you can copy the public key to the server with the ssh-copy-id command.

ssh-copy-id user@12.34.56.78

This command should generate a output similar to the one below.

The authenticity of host '12.34.56.78 (12.34.56.78)' can't be established.
RSA key fingerprint is b1:2d:33:67:ce:35:4d:5f:f3:a8:cd:c0:c4:48:86:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '12.34.56.78' (RSA) to the list of known hosts.
user@12.34.56.78's password:
Now try logging into the machine, with "ssh 'user@12.34.56.78'", and check in:

  ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

Now you can try to login without a password and it should work. To integrate Alfred in this workflow, first type the hotkey to open Alfred (Alt+Space) and then type in ssh followed by user@host for the server you want to connect to.

Awesome tip thanks to bowersrob:

speed it up a bit more (after installing brew and copy-id):

vi ~/.ssh/config and add three lines for each host you regularly connect to (example below):

Host s1 (any easy to remember “name” you will use for your connection)
HostName my_server.mydomain.com (or IP Address if static – 192.168.0.100)
User admin (whatever user name you use to login to the server with)

Save and test in Alfred:

ssh s1

At this moment you should be at least as fast as I am. If you have any question or have run into problems while following this tutorial, please leave a comment and I will get back to you.

Source: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

2 thoughts on “Use Alfred and SSH-Keys for blazing fast password-less SSH login on OSX

  1. speed it up a bit more (after installing brew and copy-id):

    vi ~/.ssh/config and add three lines for each host you regularly connect to (example below):

    Host s1 (any easy to remember “name” you will use for your connection)
    HostName my_server.mydomain.com (or IP Address if static – 192.168.0.100)
    User admin (whatever user name you use to login to the server with)

    Save and test in Alfred:

    ssh s1

Leave a Reply