Remote debug of Rust program in Visual Studio Code where VSCode sits on Windows - visual-studio-code

dear Craig McQueen!
I am referring to: Remote debug of Rust program in Visual Studio Code
My config is slightly different that is why I cannot get everything going here:
VScode installed on WIN32 with RUST components successfully!
remote system: odroid C2 ARM64 with UBUNTU18.04 with Kernel 5.14nwith IP: 192.xxx.6.x - user odroid.
I need to remote-compile a Rust program called: c2_mmap_gpio on the OdroidC2
This is already a project on the WIN32.
I did all the steps but it doesn't work.
I think it is not possible to try to run a remote_debug.sh (bash) on a windows machine, right? If yes workaround on this?
I think I need to input my user PWD somewhere to be able to ssh into the remote linux machine, right?

Correct, the remote_debug.sh I described in my answer is good only for a Linux system, and not suitable for a Windows system. For a Windows development system, you would need to write a Windows batch file or Powershell script that provides the equivalent functionality to that remote_debug.sh Bash script.
I'm not proficient in Powershell scripts, and I'm happy using Linux
as my host development machine, so I don't have plans to write such a script.
Regarding needing to enter a password for the SSH operations... Good point. That's something I didn't think to mention in my answer. You need to remove the need for a password to be entered, in one of two ways:
Install your public SSH credentials onto the target, using ssh-copy-id (or the Windows equivalent). Then you should be able to SSH to the target without needing to enter your password.
Give a blank password to the target user on the target, using passwd -d <username>. Note this reduces security, so this is not recommended, especially if the target is accessible via the public Internet.

Related

Open remote folder in local VSCode like "code ."in WSL2

Is it possible to use $ code . in remote server ssh session just like I do in WSL when I want to open current working directory in remote host in local VSCode?
ADDENDUM:
In local WSL, I can issue $ code . and that would open the current directory in VSCode which is installed on Windows 10.
I am trying to get the same behavior in another remote Linux which I have connected to remotely through ssh. So when I am on that remote machine and issue $ code . it would open that directory in VSCode installed on local window.
I don't imagine this would be simple to do but I certainly share your desire to want to be able to do it.
Problem
Here's an explanation of why it doesn't work, and a hint at why it's probably quite a difficult thing to setup:
The way code . works from WSL (or PowerShell) is by launching VS Code in the given directory (passed as the first argument as the dot).
When you run code from WSL it uses wslpath to convert the path to the Windows accessible one, and the WSL magic executes code.exe (which is, after all, a Windows binary and not a Linux one) in Windows with the WSL path (\\wsl$...);
Theory
In order for this to work you need to achieve three things:
Work out which remote you're connected to, and be able to pass that information to vscode
Execute code.exe on your local machine, but from your remote terminal
Ideas
A couple of ideas you could play with if you wanted to try and implement it:
A script on your remote could output a vscode:// URL for you to click (or find a way to get your client to auto-load it).
You might be able to use a forwarded port in your SSH session to contact something on your PC (perhaps custom made, or maybe with Windows RDP or a telnet/ssh server perhaps?)
Perhaps mount a local directory as part of your SSH connection (I don't know all the edges of SSH but it does a lot of cool stuff! SCP might help?) and be able to execute/trigger things?
Just some musings! It's not something I need enough to put any effort into it, but I came across your question looking for something else and found it interesting. Hope that's helpful to anybody, any thoughts/feedback is welcome!

Is it possible to open VSCode from Windows terminal while SSH'ed into a virtual machine?

I'm working on some tutorials and trying to do something, but no idea if it can be done. I am using windows terminal in Windows 10. I have an Ubuntu virtual machine running.
I'd like to:
Open Windows terminal
SSH into the Linux Virtual Machine
Type in the code . command and have it open a version of VS Code on my Windows PC that is working on the folder in the Ubuntu VM.
I tried install code locally and on the command line in the other machine, but it doesn't work. I am sure there are other ways to do this but wanted to explain how I was doing it to show I at least tried something. Thanks for your help.
It's not quite as easy as the code . technique you get with the Remote - WSL extension, but Microsoft also provides a Remote - SSH extension that can be used to directly access the remote machine (without requiring WSL in-the-middle).
Once the Remote - SSH extension is installed in VSCode (and it may have already been installed in an extension pack with the WSL extension), and you have installed an OpenSSH client in Windows, there are several ways to access files on the remote host through SSH:
From the Command Palette (Ctrl+Shift+P), type Remote SSH to filter on those commands. From Connect to Host, you can add a new configuration, etc.
From the Activity Bar on the left, select the Remote Explorer icon, then in the dropdown at the top, select SSH Targets. You can add hosts here through the + icon.
There's a direct shortcut to Open a Remote Window at the far left of the status bar. This will give you similar filter options on the Command Palette as above.
Once a host is configured, you can browse it just as (well, almost) if it were local, open files, edit, etc. The one thing you can't do (as far as I'm aware) is any type of sudo/su editing on files that you don't have permissions to directly.
Full details in the VSCode docs here.

Using the boto3 library with IBM COS in Windows

You provide python example code here: https://ibm-public-cos.github.io/crs-docs/python
As part of this, a Linux user needs to either use the environment variables show on the page, or set up the file in ~/.aws to hold the aws keys.
What is the analog for Windows (assuming this works under Windows)?
You could try:
> dir "%UserProfile%\.aws"
Source: https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
Alternatively, if you follow the links from the link you provided younare taken to the boto3 s3 library which describes environment variables for setting your credentials: http://boto3.readthedocs.io/en/latest/guide/configuration.html
If you are on Windows, I would recommend one of two approaches:
1) Installing Cygwin which is the most popular way to get a bash shell on a Windows environment
2) Installing Ubuntu natively on your Windows machine. Starting with Windows 10, it is now possible to run a Linux kernel natively, inside
a Windows system [1][2]. This is also referred to as "Bash on Ubuntu on Windows". There is a very cool talk with a demo about this.
Alternatively, you could continue to live in a pure Windows environment and instead set up environment variables in Windows for your Python application.
[1] https://www.microsoft.com/en-us/store/p/ubuntu/9nblggh4msv6
[2] https://learn.microsoft.com/en-us/windows/wsl/about

Eclipse PyDev use remote interpreter

is there a posibility to make eclipse PyDev use a remote Python interpreter?
I would like to do this, as the Linux Server I want to connect to has several optimization solvers (CPLEX, GUROBI etc.) running, that my script uses.
Currently I use eclipse locally to write the scripts, then copy all the files to the remote machine, log in using ssh and execute the scripts there with "python script.py".
Instead I hope to click the "run" button and just have everything executed within my eclipse IDE.
Thanks
Unfortunately no. You can remotely connect to your Linux server via Remote System Explorer (RSE). But can't use it as a remote interpreter. I use Pycharm. You can use the free Community Edition or the Professional Edition for which you have to pay for it. It is not that expensive and it has been working great for me.
As Adel says, this is probably not possible with the Remote System Explorer, or the normal Run button,
but you can automate the process you currently use. I had to do this for a few weeks when the fan was broken
in my laptop, and doing any significant computation there made it overheat and poweroff, so I just ran
everything on my work machine.
You can use the External Tools mechanism to run a short script that syncs your code to the remote server,
runs your script, then syncs back any output files to your local machine. My script looks like this,
is stored in $HOME/bin/runremote.sh, and is executable (chmod +x runremote.sh)
fp="$1" # Local path to the script we want to run--for now,
# this is the only command I pass in from Eclipse, but you could add others if so inclined.
# My home directory is a little different on my local machine than on the remote,
# but otherwise things are in the same place. Adjust as needed.
fp=`python -c "print '$fp'.replace('/home/tsbertalan', '/home/oakridge/bertalan')"`
# Run the synchronization. I use Unison, but you could use something else,
# like two calls to rsync, or a series of scp commands.
reposync >/dev/null # The redirection assumes your sync command will print errors properly on stderr.
cd='cd '`dirname $fp`
# I use a virtual environment on the remote server, since I don't have root access to install
# packages globally. But this could be any set-up command you want to run on the remote.
# A good alternative would be `source $HOME/.profile` or `~/.bashrc`.
act='source /home/oakridge/bertalan/bin/activate'
fname="`basename $fp`"
cmd="$act ; $cd ; python $fname"
# Run the command remotely. The -X forwards X11 windows, so you can see your Matplotlib plots.
# One difficulty with this method is that you might not see all your output just as it is created.
ssh bertalan#remote.server.edu -X "$cmd"
sleep 1
# My synchronization script is bidirectional, but you could just use rsync with the arguments flipped.
reposync >/dev/null
If you don't use linux or OSX locally, you'll probably have to use MinGW or Cygwin or whatever to get
this working. Or, since you appear to have a working Python interpreter, you could write an
equivalent script in Python, make it executable (by the file properties dialog in Explorer, I think),
and add a #!/path/to/python line at the top. I don't use Windows regularly, so I can't really help with that.
To use this in Eclipse, go to Run > External Tools > External Tools Configurations.... Add a new tools
whose Location is the path to your script, and whose first Argument is ${resource_loc}.
You can then use it with Run > External Tools > [first item], or bind it to a keyboard shortcut (I used F12)
by going to Windows > Preferences > Keys, and searching for "Run Last Launched External Tool". Presumably you'll
have to go through the menus first to make this the "Last Launched" external tool.

using cygwin sshd and xwin to launch window application from remote client

Could be a flaming thread but hope you dont mind a question from a curious Joe here.
I have Desktop computer running downstairs running with winxp pro,cygwin,sshd,xwin.
Whilst that, I am working upstair with my laptop and my wife will be using the desktop downstair(watching movie,etc,etc). My laptop upstairs is already loaded with Mobaxterm (which actually translate to cygwin as well).
I have already configure my desktop properly with user and ssh and xwin. When I use my laptop to ssh into desktop downstairs, starting the xclock, all works fine. I can see the xclock on my laptop.
Here is my question:
Is it possible now to run firefox(C:\Program Files\Mozilla\Firefox.exe) on my desktop via ssh and getting the display to laptop, so I could control the desktop downloading from upstairs.
After I ssh to my desktop downstair and when I try
cd \cygdrive\c\Program/ Files\Mozilla
./Firefox
Nothing came through display on my laptop.
Any advice. I know vnc could work but meaning to say it would interupt my wife work periodically where she is using on the desktop downstair. And, I have already intended to buy another nettop to do this.
Is there any solutions to this for the time being?
Thanks.
This won't work the way you are describing it. You are using SSH + Xwindows to remotely display unix programs like xclock, not native Windows apps like firefox. You need to see if you can get Firefox compiled for cygwin on X. I have no idea if it is even possible, you may want to search with keywords "firefox xwindows cygwin".
You may be able to do something with Remote Desktop, I'm not sure if it would interrupt your wife's work though. There's a write-up with using it over ssh here.