Visual Studio Code - SFTP Extension Using SSH Authentication

For me, it was enough to just use the privateKeyPath option:

...
    "host": "my.site",
    "protocol": "sftp",
    "port": 22,
    "username": "username",
    "privateKeyPath": "/Users/username/.ssh/id_rsa",
...

Note: in order to login with the key, you need to install your key to the remote server first with ssh-copy-id [email protected] command.


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.