SSH into Remote VM with VS Code | Tunneling into any cloud | GCP Demo
HTML-код
- Опубликовано: 5 июл 2024
- Are you wondering how to open a remote folder in VS Code via SSH?
That's exactly what we show you in this video. With this approach you can use Visual Studio Code on your local machine but store and run your source code on a remote machine on literally any cloud. In this live demo we are creating a virtual machine on the Google Cloud Platform (GCP) and SSH into it.
Chapters in this video:
0:00 - Intro and Explanation
01:09 - Create Virtual Machine (GCP)
02:53 - Remote SSH config in VS Code
05:19 - Private/Public Key creation (ssh-keygen)
07:19 - Add Public Key to GCP VM
08:06 - Connect to Remote VM
09:45 - Verify SSH Server is running
10:08 - Install SSH Server (optional)
18:18 - Outro
Contact us:
www.blueantoinette.com/contac...
/ blueantoinette_
Note the underscore in our Twitter Handle: @BlueAntoinette_
Blue Antoinette:
www.blueantoinette.com/
Hashtags:
#ssh #vscode #gcp - Наука
Note: If you use VMs with ephemeral IP addresses your host keys in the file ~/.ssh/known_hosts may become invalid on VM restarts. In this case you can delete the line with your VMs IP address from the ~/.ssh/known_hosts file and then connect to your VM.
Thanks
thank you very much! I can add something... you will get some errors if you choose google IAM and want to use SSH with thirds software... you must to choose carefully, cant get both google cloud IAM conections and private SSH
The HostName in the ssh config file also needs to be changed to the new one
@@silviomazzucco8891 yes, if you stop start vm google will generate different IP address
You've solved my issue my good man, thanks so much. everything clear
Glad it helped!
Thanks man. I was about the become crazy trying to figure out the Google Cloud documentation. Your tuto is simple and crystal clear.
Great to hear!
Guys, I tried N tutorials, even one where the SDK itself created the .config and only this one worked. Thank you man, you are incredible.
Glad to hear that
Thank you! This is a great tutorial!! Super clear and well-organized!
Glad it was helpful!
Thank you. This helped me setup my VS Code to my GCP instance :)
Great to hear!
Fabulous, i was missing the IdentityFile line.
Thanks man kudos
Thanks a lot for your feedback!
Thank you, it worked! I did copy the gcloud command but it didn't work, maybe some error with the ssh key. But I manually created the key and added it into the VM instance and It worked instantly. Thanks a lot!
Great, thanks for your feedback
Worked for me! Thanks for this guide 👍
You're welcome!
Wow, this is a real tutorial, very specified, an actually works, thanks
Glad it helped
I spent about a week trying to do this. My issue was specifically generating the SSH key and then adding the IdentityFile line. Thank you so much.
Glad it helped!
Best video ever uploaded to youtube, thanks man.
Glad you liked it!
Thank you so much this worked for me after spending the whole night stuck on one place
Glad it helped
Perfect!!!! Thank you very much
You're welcome!
You just saved my day!
Glad it helped!
Thanks a lot! It worked :)
Great, thanks for the feedback
Thank you so much!
You're welcome!
Huge Thanks!
You're welcome!
thank you for this video
You are welcome
this helped alooot!
Great, thx!
Thank you very very very much , you rescued me
Glad to hear that
Thanks!!
Welcome!
thanks man !
Happy to help
Awesome tutorial, but I still have an issue where I'm unable to write the files because I don't seem to have permissions... not sure how to fix ;(
Could you fix your issue? Feel free to provide more details of your error and your setup otherwise.
Thank you it works fine.But it is little bit tricky.If you want to connect to the existing VM make sure you put exact same name as it is on your existing VM at the end of the private key.Otherwise will create sibling on your existing vm and you will not be able to access the ubuntu existing files.
No changes to private keys are required.
can i use more than 1 host like remote-ssh-demo1 and remote-ssh-demo2 with different ssh key ?
Yes, just add multiple sections in your config file with IdentityFile entries pointing to different private key files.
Hello, I tried all the steps to connect to a VM in GCP via VS code on my mac book, but getting this error "Could not establish connection to "VM NAM": The operation timed out. Any help would be much appreciated.
Do you use ephemeral IP addresses? You can delete your VMs IP address from your local ~/.ssh/known_hosts file and try it again.
Tried all the steps mentioned in the video, but still getting the error "could not establish conection to " and sometimes permission denied "publickey".
Do you use ephemeral IP addresses? You can delete your VMs IP address from your local ~/.ssh/known_hosts file and try it again.
Can I do this with a local VM on my local server?
Yes, but you need to install the OpenSSH server and to enable PubkeyAuthentication in the /etc/ssh/sshd_config file.
Then create the file ~/.ssh/authorized_keys and add your public key to it.
Relevant commands e.g. on Debian 11:
sudo apt install openssh-server
sudo systemctl status ssh
sudo systemctl start ssh
sudo systemctl stop ssh
After all manipulations, i get error "could not establish to "my ssh""
Detail: I use ssh on host of site
Please check my comments on comparable requests. If it doesn’t work in your case feel free to provide more details of the error you receive along with information about which cloud provider you use.
I followed to same steps and yet the connection did not work... any idea why?
Which platform are you trying to connect to? Do you get any error messages?
@@BlueAntoinette a VM on GCP. The error was "permission denied (public key)". But the IP address is ephemeral so I will follow your advice for that case.
@@KarenP21 try to get a "static" external IP, before connect with VSC, because you will need to change IP in the config file
maybe that helps u @KarenP21
ssh-keygen -t rsa -f Path/to/.ssh/filename -C yourUserName -b 2048
For GCP its important that yourUserName matches you OS Username
it's working now :) I didnt have to use this line
Crack
?
Please how do you know the username I’m confused because isn’t working
The username by default is the first part of your email address (before the @) that you used to create the VM
This worked for about 5 minutes. Then all of a sudden I am getting a Timeout when I am trying to connect.
If it worked for 5 minutes it means that it works principally and your problem has a different cause. Maybe you restarted the VM and you received a new ephemeral IP address or your VM ran out of resources, … If you want individual consulting, feel free to check out my consulting offering at www.blueantoinette.com/product/consulting-analysis-hour/
how to get access to editing files?
Look for a .ssh directory in your home directory