Recently, I faced a problem with using Sublime SFTP extension to map my local directory to a WP Engine live installation. When I used the Sublime SFTP config to enter the login credentials, and opened a file and uploaded, it prompted “Enter ssh key passphrase for ~/.ssh/id_rsa”. When I entered my passphrase for id_rsa, it opened another field to enter the SFTP password. When I entered the password, it connected to the server successfully.
Problem
The problem was that it kept showing the same two fields one after another after every 2-3 minutes. This immediately became a nightmare because I had been working on that live site for hours.
I did many searches on Google but couldn’t find anything that could resolve this problem. I then contacted WP Engine support but they didn’t have any clue how to resolve this. They suggested another solution which didn’t work as my problem was completely different than they suggested the solution for.
So I kept digging in myself testing various things, e.g., clearing up “~/.ssh/known_hosts” file, changing Sublime SFTP config settings to keep connect alive with “keepalive” setting, but nothing did the trick. Then I tried something that resolved the problem for me. 🙂
Solution
To resolve this problem, you need to generate a new SSH key without any passphrase and then use this SSH key file name in place of “ssh_key_file” option in Sublime SFTP config. To do so, follow these steps (on Mac/Linux):
- Open terminal and type
cd ~/.ssh
- Then type
ssh-keygen
- Type name for the file to
wpengine_rsa
or any other, but remember the name as we need to use it in Sublime SFTP config file. - For the “Enter passphrase”, leave it blank
Once that is done, note down the file name, i.e., in this case “wpengine_rsa” and then follow these steps to make changes in your Sublime SFTP config:
- Open your Sublime SFTP config file i.e., sftp-config.json
- Locate “ssh_key_file” option and uncomment it.
- Set its value to “~/.ssh/wpengine_rsa”
- That’s it.
Now connect to the server again, and try to upload any file. The connection should be done without any prompts. 🙂