How to save ssh password to vscode?

To setup password-less authentication for ssh on Visual Studio Code, perform the following steps.

These examples assume the following (replace with your actual details)

Host: myhost
Local User: localuser 
Remote User: remoteuser
Remote User Home Dir: remoteuserhome
SSH Port:  22

I’m using a Mac so Windows will be a bit different but the basics are the same

Tell VS Code and your machine in general how you will be connecting to myhost




Host <myhost>
  HostName <myhost>
  User <remoteuser>
  Port 22
  PreferredAuthentications publickey
  IdentityFile "/Users/<localuser>/.ssh/<myhost>_rsa"

Next generate a public and a private key with something like OpenSSL

ssh-keygen -q -b 2048 -P "" -f /Users/<localuser>/.ssh/keys/<myhost>_rsa -t rsa

This should make two files:

<myhost>_rsa        (private key)
<myhost>    (public key)

The private key (<myhost>_rsa) can stay in the local .ssh folder

The public key (<myhost> needs to be copied to the server (<myhost>)

I did it with FTP but you can do it however you wish but it needs to end up in a similar directory on the server.


There is a file on the server which has a list of public keys inside it.


If it exists already, you need to add the contents of <myhost> to the end of the file.

If it does not exist you can use the <myhost> and rename it to authorized_keys with permissions of 600.

If everything goes according to plan you should now be able to go into terminal and type

ssh <remoteuser>@<myhost>

and you should be in without a password. The same will now apply in Visual Studio Code.

Leave a Comment