How to Setup SFTP Connection with Private SSH Key in Coda 2

To manage website, I use SFTP/SSH over FTP. When use SFTP/SSH, I choose key-based authentication over username & password. Key based login is considered much more secure than password based login. The good news is, most Linux based hosting packages allow user to active SSH access. Comparing with setting up a FTP connection in your favorite FTP client, setting up a SFTP connection with private SSH key does require few extra steps. But once it is done, you can enjoy more secure connection with less security concern.

As my favorite code editor, Coda 2 takes up desktop screen most of the time. It is text editor, FTP client, terminal & MySQL client all-in-one. But its documentation isn’t helpful in terms of SFTP/SSH setup. I had some confusing experience with Coda that the SFTP connection not working. Failed attempts taught me how to setup SFTP with Private SSH key in Coda the right way. In this post, I will use a brand new configuration as an example, to show you how to add a new SFTP connection in Coda 2.

Get the Private SSH Key

  1. Login to your website CPanel, and locate the SSH/Shell Access icon (in security section).
    ssh-shell-access-icon
  2. Make sure you have enabled SSH Access in Manage SSH Access. (1st time setup may requires an account verification over the phone with hosting provider)
  3. Click Manage SSH Keys
  4. For the 1st time setup, you have a blank table without public key and private key. Click on Generate a new key.
  5. In SSH Key Generator, key in (and remember) the Key Password, you’ll need for Code setup. Select RSA over DSA, choose 2048 for Key Size if you prefer enhanced security. Click Generate Key to create the public SSH Key.
    ssh_key_generator
  6. Go back to Manage SSH Keys page, in Public Keys section, click on Manage Authorization to authorize the key for use to connect to this account.
  7. In Private Keys section, click View/Download to download the private key to your local computer.manage-ssh-keys

Setup a Site with SFTP Connection in Coda

  1. Before rushing into Coda, we need to add the SSH key to keychain. To do so, I use ssh-add command in Terminal. (You shall chmod the key file to 600, otherwise, you may have trouble later on)
    The command is 

    ssh-add -K /path-to-file/ssh_key_filename

    You will be asked for passphrase created during the step 5 in previous process “Get the Private SSH Key

    Screen-Shot-2013-08-08-at-4.29.29-PM

  2. If Code is already launched, shutdown and restart.
  3. Add a new site in Coda, in Site setting, select SFTP as protocol, enter your username, but leave the password empty.
    coda-site-setting
  4. Click on the Key icon beside Password box, and manually select the private key file we saved in previous step 7.
  5. (If you’ve done it properly, Coda should prompt for passphrase). Enter the passphrase for the private key.
    coda-private-key-passphrase
  6. Click OK, and then Save setting.

Try to connect, you should see the remote file directory as normal. Happy Coda!!

(If you still can’t connect by any chance, try to complete quit Coda and restart it).

 

Comments are closed.

Post Navigation