Remote Development using SSH on VS Code
I have to say amazing after remote ssh on vs code. Debugging and preview remote on vs code is what I want for a long time. What a pity, it's too late to meet 🤣.
The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code's feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem.
Step1: Generate an SSH Key
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/user-name/.ssh/id_rsa): input the absolute path here.
Enter passphrase (empty for no passphrase):
Then, you got two file in your
.ssh directory. Something like
Step2: Copy the key to a server
Once an SSH key has been created, the ssh-copy-id command can be used to install it as an authorized key on the server. Once the key has been authorized for SSH, it grants access to the server without a password.
ssh-copy-id -i ~/.ssh/mykey user@host
Only the public key is copied to the server. The private key should never be copied to another machine.
Step3: Install VS Code extension
Step4:Create a config file
Host aws-ec2 HostName 22.214.171.124 User ubuntu IdentityFile /Users/user-name/.ssh/file-name
- Host (aws-ec2) is just a name that will appear in VS Code. It can be any name. - HostName is the server’s host or IP. - User is the Ubuntu username. - IdentityFile is the path to the private key.
Step5:Configure in VS Code
- Show all command to find remote-ssh
- Excute the Connect to Host
Configure SSH Hosts
Setting configure path
- Excute the Connect to Host Select one you have configired.
Enjoy remote developing, debug and preview locally with the power of VS Code.
Thanks for your reading.
Have a good day.
Did you find this article valuable?
Support Lizhiyu by becoming a sponsor. Any amount is appreciated!