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.

15 thoughts on “Make your SSH keys work in Coda 2”

  1. Vito says:

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

  2. Johnny says:

    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.

    1. Johnny says:

      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.

      1. Johnny says:

        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):

        Host ssh.myleetbox.com 1.2.3.4
        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!

      2. Johnny says:

        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:

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

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

        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.

    2. Johnny says:

      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. I’ve found a solution to my issue that is detailed here:
    https://groups.google.com/forum/#!topic/coda-users/7NOHRAzsZYs

  5. Hose-san says:

    It has corrected thanks to you!!

  6. Nick Momrik says:

    Saved my life on new computer. I was going nuts!

    1. joen says:

      Makes me happy I was able to help you!

  7. J. Hogue says:

    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.

  8. marushu says:

    Thank you so much!!
    I was able to connect 😀

  9. quefaccion says:

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

  10. Steve says:

    Wonderful. Thank-you very much. I was about to give up on using Coda 2.

Comments are closed.