Sublime Forum

How to connect SFTP with SSH key

#1

Hi

I have installed SFTP and want to configure the SFTP connection to use an SSH key instead of a password.

I’ve added a public key to my server in a .ssh/authorized_keys folder but I am a it confused by the ftp configuration file.

Can anyone help please?

Its pretty standard, but this is what I have:

{
// The tab key will cycle through the settings when first created
// Visit wbond.net/sublime_packages/sftp/settings for help

// sftp, ftp or ftps
"type": "sftp",

"sync_down_on_open": false,

"host": "example.com",
"user": "username",
//"password": "password",
//"port": "22",

"remote_path": "/public_html/",
//"file_permissions": "664",
//"dir_permissions": "775",

//"extra_list_connections": 0,

"connect_timeout": 30,
//"keepalive": 120,
//"ftp_passive_mode": true,
//"ssh_key_file": "~/.ssh/id_rsa",
//"sftp_flags": "-F", "/path/to/ssh_config"],

//"preserve_modification_times": false,
//"remote_time_offset_in_hours": 0,
//"remote_encoding": "utf-8",
//"remote_locale": "C",

}

2 Likes

#2

@jkw Nope, I saw that thanks

I guess the starting point for my issue is I have no idea where or how to set

//"ssh_key_file": "~/.ssh/id_rsa",

I’ve got a .ppk private key and I’ve loaded it into Pageant which is running in the background but how or where can I find the above folder for storing the key?
Also, would I need to add the hostname and username if I am connecting with a SSH key?

0 Likes

#3

Hi,
If you are using linux (ubuntu) then here is what you need to do:
1- copy private key with a password to the ~/.ssh folder
2- Solution for a possible WARNING: UNPROTECTED PRIVATE KEY FILE!

sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 755 ~/.ssh

3- As you also mentioned above, you’ll need to uncomment the line “ssh_key_file”: “~/.ssh/id_rsa”,
4- Make sure you specify the port for ssh to your server if it is not the default port “port”: “22 OR your server’s ssh port”,
5- I would recommend to uncomment //“keepalive”: 120, to your specific time in seconds not to get annoying insert your ssh key’s password message (it will send some dummy command to your server just to keep the ssh connection active).
Tada! you should be all set to go!

Additional note:
I hope I am not too late as it reads this question was posted on May 2013!

0 Likes

#4

In case this helps anyone else, using subllimetext with sftp for ssh access on a siteground server. The above post by webdesignmzm worked for me when the chmod commands where altered to reflect the .ppk file’s name (moved into the .ssh folder). *I did not use id_rsa.

Cheers

0 Likes