I have managed to install the OpenSSH on my windows server and am able to ssh from my computer. But I am facing some weird issues after ssh into the server. When I try to move around like running cd it works but when I try to create a file and etc it prompted me that the command is invalid.
I have used this tutorial to set up the OpenSSH on my windows server.
Is powershell installed on your server?
Looks like powershell is not installed.
What I see now, you are connected with regular cmd, not with powershell.
Try to start Powershell first
Related
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.
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!
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.
I'm Currently trying to setup Remote developement environment with VS code.
I have installed Remote - SSH plugin and edited my .ssh/config file as below
Host ABC
User ubuntu
HostName xx.xx.xx.xx
IdentityFile ~/.ssh/filename
It trowing an error by saying "An SSH Installation couldn't be found"
Local Machine - Windows
Host Machine - Ubuntu(Linux)
Please help on this matter
You are missing an SSH tool in your host machine. Popular implementation of SSH protocol, OpenSSH is installed by default in Windows 10. First confirm if you have OpenSSH client by going to
Windows Settings >> Apps & features >> Optional Features
If not, install OpenSSH client through "Add a feature" option at the optional features page.
Mostly VSCode can pick the executable from common installation locations of the ssh.exe. If still not able to resolve, add the property below in VSCode settings
"remote.SSH.path": "your/ssh.exe/path"
like
"remote.SSH.path": "C:\Windows\System32\OpenSSH"
I have Windows 10 - 1608 version and it doesen't exist OpenSSH Feature in >> Optional Features.
I had downlosded OpenSSH seporately and now it's working as expected.
and another mistake I have done. I have tried to connect with .ppk key as the IdentityFile. And I have converted to private key using puttyGen. It is working perfectly now
Thanks for the help guys. Openssh was not present so had to install OpenSSH from Windows Powershell
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
Then copied the path of ssh.exe to VScode settings. Ex:
"remote.SSH.path": "C:\Program Files\OpenSSH-Win64\ssh.exe"
It worked perfectly.
Instead of installing OpenSSH, installing Git on Windows 7 also works because Git for Windows installs the SSH client. It ships OpenSSH with the package.
So I am just trying to convert to powershell from bash. I was trying to find a way to SSH my server, and found out I could install win32-openssh to do so.
I installed it by:
Installing chocolatey as packageprovider using:
install-packageprovider chocolatey
Then i installed win32-openssh with the command:
install-package win32-openssh
My problem is now, how do I run this program?
It installs the correct binaries etc. It will not add some PS cmdlets for the use off ssh inside PS.
It is all described on the package site:
This package performs the following operations that you normally have to hack at until you get what you want:
Install Appropriate Bitness for the version of Windows
Install to Program Files (malware protection and following advice of dev team)
Add SSH location to System PATH
Optionally install sshd windows service (Requires parameter - see below)
Optionally install sshd server "key based authentication" (Requires parameter - see below)
Cleanly uninstall all of the above (removing config files and server keys requires special switch - see below)
So you can run it from start menu, or by typing ssh.exe into a prompt.
You have Two Options I can think of.
Option 1 : Use bash on Windows 10. Bash comes bundled with Windows 10. You can just enable a Windows 10 feature for it. Setup bash on Windows 10. You'll never miss bash again even if you're on Windows. [Recommended Option]
Option 2 : Set up SSH on Powershell by installing a package like PoSH-SSH.
Steps :
Pre-requisite : PC running Windows 10. Open PowerShell in Admin mode.
Find-Module PoSH-SSH
type 'Y' for the prompts.
Install-Module Posh-SSH
type 'A' for the prompts.
Reference:
https://www.thomasmaurer.ch/2016/04/using-ssh-with-powershell/
There's not really a need for this. If you have git installed on your Windows machine, you can add it's usr/bin folder to you path. It has ssh and other Unix tools you can use just like in Bash in PowerShell or CMD.