This is yet another tutorial/note to help you set up a VS Code that connects to a machine and allows you to work remotely in a LAN. Sure there are tons of video and documents, but I think they really complicated things, the connection setup is really easy, basically telling the remote machine:
hey, this is me, the real one.
Summarize the steps in a quick way as follows:
Generate the Identity
Generate an SSH key pair on your machine that runs the VSCode locally, for example, my case is on Windows. Open a powershell and type:
ssh-keygen -t rsa -b 2048 # or 4096
Go through the generation steps, specify the file path such as C:\User\<you>\<rsa_file>
,
after done, you will see <rsa_file>
and a <rsa_file>.pub
under the directory,
the latter one is what you need to copy to your remote machine.
Let the Remote Know
SSH to your remote machine, look for `~/.ssh/authorized_keys, if not, create one with your favorite editor.
vim ~/.ssh/authorized_keys
Config VSCode
Copy the
<rsa_file>.pub
to above fileConfig the VS code
Install the Remote - SSH plugin
Install the Remote - SSH Config plugin
Host <whatever you like to call> HostName <your remote host name> User <your login> IdentityFile "path to your rsa_file" # no .pub!
Done!