Make Your SSH Keys Work in Coda 2

This post is authored for Google, to help out others searching for solutions to Coda 2’s SSH woes.

Since Coda 2 was released, 2.0.1 and 2.0.2 have made strides to improve things, so upgrading is your first step. If you’re still experiencing trouble with Coda accepting your SSH keys, and/or get error messages such as “unable to extract public key from private key file”, try this:

  1. Set up your site as usual — enter username, servername and so on
  2. Click the key icon next to the password box to manually point to the id_rsa key-file (which I’d assume you’ve stored in ~/.ssh)
  3. Check the box “Ask each time”
  4. Save site, connect;  when asked, input SSH key password in the prompt
  5. Behold how it connects
  6. Disconnect, edit site, uncheck “Prompt everytime”

Let me know if the above works for you, it worked for me.

Make Your SSH Keys Work in Coda 2

13 responses to “Make Your SSH Keys Work in Coda 2”

  1. I was getting crazy. worked! thanks! Paid $75 license yesterday and can’t believe they don’t fix such a simple bug…

  2. I am using Coda 2.0.7 and this bug is no longer in it. However, one annoyance with Coda is that it does not allow you to use a public key under Terminal setup. They force you to use password-based sign-ins. If your server is set up to only allow crypto logins then this won’t work. Argh.

    • Oh wait, there is a workaround!

      First, add the public key to your SSH keychain:

      ssh-add -K ~/path_to_key/user_id_rsa

      Then just edit the Terminal settings in Coda and leave the password blank.

      I don’t know how secure this is. Like whether or not this means that the added key will be automatically tried for EVERY SSH system you ever connect to. I am not sure if there’s a way to set up the ssh-add command to ONLY use that key when you connect to your desired hostname/IP.

      Of course the best solution would just be for Coda to get their sh-t together and add keyfiles to the Terminal tab as well.

      • Aha, here I come to the rescue! Don’t use the command I wrote above. I have found the solution to doing this safely!

        Alright, do this:

        * Step one: Download the key to your ~/.ssh folder, calling it something like ~/.ssh/mysecret.key

        * Step two: Edit or create ~/config:

        vi ~/config

        * Step three: Add the host and identityfile directives (you only have to add the IP too if you occasionally connect via the direct IP rather than hostname; you can add as many hosts as you want separated by spaces):

        IdentityFile ~/.ssh/mysecret.key

        * Step four: There is no step four. You can now login to that box as any user for which the key matches. So just add your system to Coda’s Terminal tab and that’s it. In fact, you don’t even have to provide a password/keyfile on Coda’s SFTP-login page either. It’s all taken care of and will automatically use the correct key no matter what program tries to connect to the server!

      • Some extra details: The “Host” directive makes all commands following it apply only to that specific host. You can have multiple Host directives in a file, for more than server, like this:

        IdentityFile ~/server1.key
        Host *
        IdentityFile ~/server2.key

        Also note that the latter example used a wildcard to match any subdomain of!

        You can restrict it per port and user on the server and other things too.

        Read “man ssh_config” for full details. It’s powerful.

    • Oops, sorry everyone, I was looking through what I had written here and spotted an error:

      vi ~/config

      was supposed to say:

      vi ~/.ssh/config

      Otherwise it’s created in the home folder rather than the proper .ssh subfolder. This was just a typo on my part when I wrote my posts.

      Well, that’s it, enjoy! Now you know how to set up key-based logins that work with Coda both for SFTP and Terminal access! 😉

  3. Using Coda 2.0.7 — The terminal login works effortlessly using the ssh config with the IdentityFile option.

    However, no go with SFTP and ssh keys using coda. Any key I generate, except for the default id_rsa key, won’t save when I select them in the Edit Site… dialogue. It tells me the key is not in the correct format. Since I now generate a new key for each site I work on, I’m having to resort to using the password interface to use the SFTP feature in coda. Bummer…

  4. It should be noted, as of Coda 2.0.11, it may still try to tell you that the key is not in the correct format (I generated a RSA key locally with Terminal in ~/.ssh, and I get this error: ‘Could not import SSH key file. The file is not in a supported format.’). But if you plod on and try to connect, then enter your passphrase, it should still work. At least, it did for me.

  5. I was able to get it recognize my key by adding it to the Config file at ~/.ssh/config.