Issue
I'm using the vscode-sftp extension in my Visual Studio Code workflow to upload files to my remote server, whenever I hit save. I am trying to achieve password-less authentication as I used to do with Sublime Text's SFTP plugin. However, the catch is that for vscode-sftp, in the sftp.json
file, I have to enter my Password as plain text for this to work:
{
"host": "mysamplehost.com",
"port": 22,
"username": "username",
"password": "password",
"protocol": "sftp",
"agent": null,
"privateKeyPath": null,
"passphrase": null,
"passive": false,
"interactiveAuth": false,
"remotePath": "/",
"uploadOnSave": true,
...
}
However, if I SSH into my server, I do not get asked for a password - since I have the SSH key in my MacBook. How do I configure vscode-sftp to use this authentication method?
I see the following comment in the documentation, however I don't know how to set this up:
/**
* string - Path to ssh-agent's UNIX socket for ssh-agent-based user authentication.
* Windows users: set to 'pageant' for authenticating with Pageant or (actual) path to a cygwin "UNIX socket.
*/
agent: null,
privateKeyPath: null, // absolute path to user private key
passphrase: null,
passive: false, // ftp passive mode
Solution
I figured it out after stumbling upon this. Here is how I did it. First, run:
$ echo $SSH_AUTH_SOCK
Enter the path to agent
in your sftp.json
file. Also enter the path to your private key (id_rsa file). The following config did the trick for me:
"agent": "/private/tmp/com.apple.launchd.nPw17MhOqq/Listeners",
"privateKeyPath": "/Users/amitsn/.ssh/id_rsa",
"passphrase": null,
Note that I do not have a passphrase, so I left it null. Do not forget to fill this one if you have one.
Answered By - Amit Answer Checked By - Marie Seifert (WPSolving Admin)