Visual Studio Code Remote Development using SSH to Raspbian - visual-studio-code

I want to run Visual Studio Code Remote Development using SSH to my Raspberry Pi 3 Model B+ running Raspbian GNU/Linux 9 (stretch).
I have tried to follow the "Getting started" instructions. I run the command Remote-SSH: Connect to Host..., but I get the message Can't connect to admin#pihole.local: unreachable or not Linux x86_64 (Linux armv7l )
As far as I know, Raspbian is 32 bit. So, does this mean that what I want to achieve is impossible?
I can connect to the Raspberry Pi using ssh on the command line without problems (not password based).
I'm running VS Code insiders on macOS Mojave 10.14.4.

Update 2: As of the 10th of February, x86_64, ARMv7l (AArch32) and ARMv8l (AArch64) are the supported Linux architectures for Remote SSH. It it appears that a glibc based Linux distribution is needed to meet certain prerequisites/dependencies. There is also experimental support for Windows 10/Windows Server 2016/2019 in the Insiders builds. More information can be found on the prerequisites information page.
Update: As of the 12th of June, approximately one month after my answer to this, support was added for the Raspberry Pi 3. There is no support for other ARM architectures yet, and this does not work with the Raspberry Pi Zero W yet, but I'm not sure about the Raspberry Pi 1 or 2. One point to note at present is that you need to setup public key authentication so you have passwordless login, otherwise you'll need to enter your Raspberry Pi's password multiple times, and it will ultimately fail. Also, as mentioned in a comment, if you've tried the 'stable' Remote Development extensions and found out they didn't work... you need to make sure you remove them from both VSCode AND your Raspberry Pi... else it really won't work. This is also mentioned in the Github issue.
Because of how the Remote SSH function actually work, when you connect to your SSH host, the Remote SSH extension provisions the so-called VS Code Server to that host, so the VS Code Server has to be able to run in your remote environment. Consequently, at present, each architecture may need different implementations or tweaks, before it will be considered 'supported'. At the time of writing, there are no armv7l builds, but this recently changed. We're still early days for this useful looking functionality... but things are changing quickly... There is no Windows or MacOS SSH host support at present... but this may not be the case in another months time.
There is an issue open on GitHub on this topic, so it may be worth keeping an eye on it or subscribing to it to see if/when support is added.

Related

Visual Studio Code remote access to a WSL2:ubuntu on my desktop from my macbook

've looked around and can't seem to find the answer to this - probably because the feature is pretty new.
I tried the remote WSL:ubuntu connection on my windows desktop machine to connect to my WSL2 Ubuntu running on the same machine. This is pretty much perfect as it allows access to my Nvidia GPU under linux
Is there anyway I can do the same trick from my macbook? I can connect to the windows side of the desktop using the new remote tunnel feature but I'm drawing a blank on how to do for the WSL buried in that machine. It looks like it's just using the same remote connection feature so I'm thinking it should be possible but WSL2 network is not exposed the same way you can with a VM or other machine.
The desktop has way more everything than my macbook including a nvidia GPU I want to use for some machine learning.
I can do it from the desktop itself - but it's nice to be able to use that machine from my macbook at certain times of day.
I have recently started using VSCode so I'm on the learning curve with it - it may well be that it's not possible using the new remote tunnels - or requires some messing with adding a new hyper-v bridged adapter to the WSL installation. I'm hoping against hope there's an easy solve that I've somehow missed.
I tried setting up the remote tunnel as per https://code.visualstudio.com/blogs/2022/12/07/remote-even-better but it seems to setup a server to access windows not the WSL2 service.
Thanks for any help!
I had a similar problem and found this github issue. While the developers are looking into including this feature, you currently will need to install the VSCode CLI directly in WSL. You can find the downloads here
Notes
I would recommend the x64 CLI download in the Linux section. It will download a tar.gz file which will have a file named code in it when extracted.
The tunnel will launch from wherever you place that code file, so I put mine in the ~/ (home) directory.
You can then open a tunnel using the command ./code tunnel from that location. You can replace the . with the path to the code file to open the tunnel while in a different directory, i.e. ~/code.
You can still launch a tunnel from Windows with code tunnel. (note that this command does not have ./)

Using VSCode with a Raspberry Pi 1

I'm trying to set-up Raspberry Pi 1 with VSCode so I could run code remotely on it. I've installed VSCode on the Pi, but when trying to launch it with the 'code' command, I get an 'Illegal instruction' error.
I tried connecting remotely from my Windows workstation, but I got an error saying that "the remote's host architecture isn't supported".
My question is, is it possible to install VSCode on the original Pi? If not, what IDE do you use to work remotely on it, besides ssh and VNC?
According to VS Code's official site, Raspberry Pi 1 is not supported.
First-generation Raspberry Pi modules and Raspberry Pi Zero are not supported as they only include an ARMv6 CPU.
Seems to me Raspberry Pi 1 has very low hardware and I'm sure that it will give you hard times when you codding. If you wanna use it anyway, you may continue with a browser-based editor like AWS cloud9.

VS Code remote server extension shows "attempting to reconnect"

I use Visual Studio Code and RemoteSSH extension to connect to a remote server located across the ocean via the corporate VPN, The connection gets established when I connect via my mobile hotspot, but it keeps showing "Attempting to reconnect" asking for password repeatedly when I use my broadband.
I have compared the internet speed of both the service providers and below are the results.
1)Airtel hotspot(remote ssh works)
2)Hathway broadband(remote ssh does'nt work)
From the above images it is evident that my broadband speed(upload and download) is much better than my internet hotspot speed, In spite of this I am unable to use remote ssh to code using my broadband network, Is there something that needs to be tweaked, or are the internet speed tests in a way inaccurate?
I had similar experience and there are many threads on the subject, none of which resolved it for me.
I am working on a Windows laptop and connecting to remote Centos linux.
I also connect to company network via their VPN.
I resolved it in the following manner, maybe not all steps are required, but this is what I did -but firstly, I setup ssh keys so as not to have to keep using a password, well worth the effort.
Updated the fileWatcher in code to ignore .git folder and venv folder, this improves performance
Updated WSL to WSL2
Install a linux shell on Windows - I was already using an Ubuntu one, installed prior to vscode, but hints online suggested installing it after vscode, so I installed the Kali shell.
Installed openssh-server (to get ssh-keygen) on kali
Launched code from the kali shell, let it do its setup
Even though all extensions were installed on both machine, vscode didn't recognize that and I had to use the option in the extension section to "install exentsions on remote server"
After that, every thing was fine.
Hope that helps anyone else searching this problem.
In Airtel hotspot, your public IP address remains the same.
In case of Hathway broadband, public IP changes very frequently. So, if your VPN is redirecting you over IP, there may be possibility of delay because of authentication verification.

Developing Flutter with VSCode and WSL2

Since I mostly develop Web, using nginx, PHP and MySQL, I have ported my WebDev-environment entirely to WSL2.
Since performance is very important, all my web-related projects reside on the WSL2-vhdx file /home/user/Projects/Web. In WSL2 I've installed all my necessary tools for a nice and neat Linux-like experience, Docker, GIT, etc.. This combined with VSCode remote integration works very well.
Now, I'm digging into building Flutter-Apps, and my Flutter-environment is installed on the Windows side. My Flutter-related projects reside on D:\Projects\Flutter which is a partition, and NOT USED in WSL2 in any way. Building Flutter-apps with flutter-windows-sdk and VSCode works neatly.
But, the problem is: Now I've my project files scattered all across my computer. Web-stuff in a WSL2-vhdx-file and Flutter-stuff on the D-partition.
Is there a way to build flutter-apps with Flutter, while having the project-files stored on a WSL2-vhdx-file, in combination with VSCode-remote and an Android-emulator?
I tried creating a test Flutter-project on the \\wsl$ network mount, which didn't work.
Moving my web-related project files to the D:\ partition of Windows is no option, since the I/O mounts in WSL2 are extremely slow.
I got it working, reliably with adb connect 192.168.xxx
For anyone interested, see my full blog post here: https://dnmc.in/2021/01/25/setting-up-flutter-natively-with-wsl2-vs-code-hot-reload/
Is there a way to build flutter-apps with Flutter, while having the project-files stored on a WSL2-vhdx-file, in combination with VSCode-remote and an Android-emulator?
I'm assuming (based on the mention of VS Code Remoting) that you want to run the extension in WSL. I haven't tried that specifically, but I have run Flutter inside WSL and also connected a VS Code Remoting session to an Android emulator in the cloud, so I would expect this to work.
You'll need to make sure you set up the Flutter SDK inside WSL (so you can run flutter commands inside WSL - it should be the Linux version of the Flutter SDK and not the Windows one if you're using the zip).
To have your emulator show up in flutter devices from inside WSL, you will likely need to run adb tcpip 5555 from the Windows side (this means you need an Android SDK in Windows) - this will tell your phone to listen on TCP port 5555. Then you'll need to run adb connect [phone ip]:5555 from inside WSL (this means you'll need an Android SDK in Linux). If all goes well, the phone should then show up in adb devices and also be picked up by the device selector in VS Code.
I tried creating a test Flutter-project on the \wsl$ network mount, which didn't work.
It's not clear what went wrong here, though my first guess would be that maybe the UNC path isn't supported - if you map a drive letter to it does it make a difference?
While this isn't an officially supported setup, feel free to raise issues in the Dart-Code repository on GitHub with any issues you have. It's not a priority, but I would like for VS Code Remoting (including WSL and Docker) to generally work for Dart and Flutter dev.
Anytime you're crossing/sharing the file-system boundary from windows to wsl you're paying a massive cost in speed/time.
With the setup you've described I'd consider trying to self-host the browser based VSCode.dev inside wsl - checkout details instructions here: https://medium.com/geekculture/3-steps-to-code-from-anywhere-45401247f479
Personally I've settled on running VSCode and docker inside a Linux VM on Windows, and have a 96% time saving in things like running up a server and watching code for changes making this setup my preferred way now.
The standardisation of devcontainer.json and being able to use github codespaces if you're away from your normal dev machine make this whole setup a pleasure to use.
see https://stackoverflow.com/a/72787362/183005 for detailed timing comparison and setup details

With RealVNC and a Raspberry Pi, how can I connect to the same session as the raspberry itself?

I have a Raspberry Pi with Raspbian Wheezy installed. I'm using TightVNC server on the Raspberry Pi and RealVNC on my MAC to connect to it. However, when I log in with RealVNC, I'm given a new session, with my own desktop, applications etc.
I want to login to the SAME session as the already running Raspberry, so I can refresh the browser etc (We're using this to display a company desktop application).
How can I achieve this?
I don't believe this is supported by TightVNC (which I think only does "Virtual" sessions). But I may be wrong...
The answer here: https://serverfault.com/questions/27044/how-to-vnc-into-an-existing-x-session suggests a few alternatives (at least ones which work on Fedora based Unix distros)
I know RealVNC can do it (it's known as "User Mode" or "Service Mode" as opposed to "Virtual Desktop" mode), but depending on your users, you may have to license it, or the free mode may suffice.