bash: powershell: command not found - powershell

For a node project I will have to work on a remote server and for that I will use filzilla for file transfer and ssh for console.
I use Visual Studio Code, I installed a remote ssh extension,
I did the hostname and user configurations as well as secretkey,
because before that I had another error The process tried to write to a nonexistent pipe ,
which I finally solved but now after I start ssh and log in with the password in cmd from Visual Studio Code, I get this error bash: powershell: command not found.
I tried one day to search the internet for that error.
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration?WT.mc_id=-blog-scottha
https://learn.microsoft.com/en-us/windows/wsl/troubleshooting
I've talked to people who have more experience but within the time limit my advice could be, but I still couldn't solve the error, either it's something from windows or ssh or I don't know.
You are the first time I try to do this in general I used heroku or aws that had some facilities.

I changed host machine in the settings JSON file windows to linux

When you got the option to Select Linux, Windows or Mac did you make sure that you know exactly the type of server you are connecting to. Bcs if you choose the wrong one this error gets thrown.

Related

Disable install of VS Code server

I use my VS Code remote - SSH extension to jump between a lot my customers servers, and would actually like not install the VS Code server on every server that I use.
Is there a way not to install the VS Code server, when you use the Remote - SSH extension, or is there maybe even another extension I should use instead?
To fix this on your own (without using the script mentioned above), you could simply log into each of the linux. cs servers (using SSH), then the command pkill -u node , which will stop any running vscode-server processes
I fixed it but not using the official remote - SSH, but the extension SSH FS, which is a little more combersome as it can see you'r "normal" ssh config, but i works.
https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs

Manage to connect through the terminal, but not through the remote explorer

I am coming from notepad, and am learning how to work with VS Code.
I am now trying to access my online repertory on the webserver.
I followed up the guide here: https://code.visualstudio.com/docs/remote/ssh
I did manage to access my server through the terminal window.
(ssh user#domain + password).
When connecting, this shows in the log:
"Linux infong-eu27 4.4.246-icpu-061 #2 SMP Thu Nov 26 10:58:41 UTC 2020 x86_64"
This tells me that it is working on Linux.
If I type "Ls", I can see my folders and navigate among them.
So far, so good!
Second phase: Connecting through the remote explorer.
Step 1:
I configured the ssh with the same credentials I used with the terminal.
Step 2:
I am opening the remote explorer, I can see my server's name. I right click on it and select "connect".
Step 3:
I am then asking to choose the system. I am picking Linux as shown earlier when connecting through the terminal.
Step 4: I am entering the same password I used before to connect in the terminal.
Step 5: Infinite loading, or a very long one till I get 2 notifications / errors:
Could not fetch remote environment
Failed to connect to the remote extension host (error time limit..)
That being said, it also says in the bottom left corner, in the "remote window", that I am connected. This does not seems right.
Any chance someone could help?
I am frustrated because it connects in 1s using the terminal, but not in the remote explorer.
UPDATE:
I found this article on medium that paraphrases the official documentation.
https://medium.com/#sujaypillai/connect-to-your-remote-servers-from-visual-studio-code-eb5a5875e348
I managed, through Git bash, to create a ssh pair key, and managed to copy one on my server.
I then followed the instructions on how to set it up on VS Code successfully!
Now, when I try to connect, I am asked for my key pass:
But, when I do: super long loading, and the same error message.
When I looked on my server with a sftp software, I see that VS did manage to connect as files were installed in a VS folder it created:
This is reported in issue 4415 (no answer) and issue 4204
The last one includes:
This might be caused by our new automatic port forwarding feature which scans the remote OS for available ports in order to forward them locally (microsoft/vscode#112843)
This is fixed by PR 113342, for the next 1.54 Feb. 2021 release. That bug is about setting remote.autoForwardPorts to false and... still seeing VSCode auto-forward ports!
Check on your server (while VSCode attempts to connect) if:
the CPU is high
if there are any services running on public port on said server
I solved a similar issue by following the error logs from the remote ssh extension. I had to install libatomic1 on the remote server with
sudo apt-get install libatomic1

VS Code Remote SSH Connection not working

Im trying to setup vscode with the remote developement extensions on a second pc. While it works on my main one it doesnt on the second one. Tried reinstalling vscode, extensions and using older versions but nothing works.
When trying to connect it cancels after chosing the os. So I cant even type in the password.
I set it up in the exact same way as with the other pc.
Any ideas?
[20:32:53.595] remote-ssh#0.55.0
[20:32:53.595] win32 x64
[20:32:53.596] SSH Resolver called for "ssh-remote+ssh.blabla", attempt 1
[20:32:53.597] SSH Resolver called for host: ssh.blabla
[20:32:53.597] Setting up SSH remote "ssh.blabla"
[20:32:53.610] Using commit id "58bb7b2331731bf72587010e943852e13e6fd3cf" and quality "stable" for server
[20:32:53.612] Install and start server if needed
[20:32:54.639] Checking ssh with "ssh -V"
[20:32:54.686] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[20:32:54.691] Running script with connection command: ssh -T -D 52819 ssh.blabla bash
[20:32:54.694] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[20:32:54.758] >
]0;C:\WINDOWS\System32\cmd.exe
[20:32:54.758] Got some output, clearing connection timeout
[20:32:54.785] >
[20:32:55.045] > root#blabla's password:
[20:32:55.045] Showing password prompt
[20:32:57.596] "install" terminal command done
[20:32:57.597] Install terminal quit with output: root#blabla's password:
[20:32:57.597] Received install output: root#blabla's password:
[20:32:57.598] Stopped parsing output early. Remaining text: root#blabla's password:
[20:32:57.598] Failed to parse remote port from server output
[20:32:57.603] Resolver error: Error:
at Function.Create (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130564)
at Object.t.handleInstallOutput (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:127671)
at I (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:106775)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:104774
at async Object.t.withShowDetailsEvent (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:109845)
at async Object.t.resolve (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:107960)
at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:141955
[20:32:57.606] ------
[20:32:59.376] Password dialog canceled
[20:32:59.376] "install" terminal command canceled```
Depending on the system you are in, when you first try to connect, a vscode-server will be set up and configured on your server.
In linux that can be in /Home/<user>/.vscode-server
If you are on windows, check what that is.
The first solution is to try the extension command: Remote-SSH: kill VS Code Server on Host
Open the command pallet (CTRL + SHIFT + P or COMMAND + SHIFT + P (mac) ).
And type Remote kill :
Then try to connect again! (That will kill the server on the host! Which will make it start again on the next try)
If that doesn't work, and things are still failing:
Delete, rm
Then a good solution that can work is: to connect to your server through terminal (vscode terminal, gnome-terminal, whatever). Then go and remove /Home/<user>/.vscode-server
Try to connect after that. At the attempt the server will be re-installed completely anew, chances are it will work. (I did that and it worked for me, so whatever that was going wrong on the vscode-server: just start all over)
But again: you will lose things, config, meta data, etc. (because you start anew).
Update:
As stated by #natevw in the comments:
I found that removing only the .vscode-server/bin subfolder helped straighten things out and afaict kept my data/settings.
Removing only vscode-server/bin seems to work well, and the config, metadata, etc. remains untouched.
I downgrade Remote-SSH plugin to 0.51.0, rm -rf $HOME/.vscode-server on the remote machine. Connect again, VSCode will download and install a new .vscode-server. Then upgrade Remote-SSH plugin, everything works.
One way worked for me is, by adding this line in the vscode settings (JSON) file.
"remote.SSH.useLocalServer": false
I met the same problem. After I did these steps, it works:
on the remote server:
rm -rf ~/.vscode-server
rm -rf ~/.vscode
On the local VS code:
reinstall remote-ssh
In case all the above fails, here's how I fixed my issue.
First, I was able to SSH into my remote server (Ubuntu 22.04, Raspberry Pi 4, arm64) using a simple bash terminal. So I logged in using my terminal (macOS), and I went to
cd $HOME/.vscode-server/bin/WHATEVER-HASH-YOU-HAVE/
In this directory, there is a file named server.sh. I tried running this script, and I got the following error:
./node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
The issue was clear: there was a missing shared library on my system. Either Node.js now requires that or the new version of the SSH-Remote extension; I don't know. I did not spent the time to dig into those specifics.
But to fix that, I simply did:
sudo apt-get install libatomic1
That installed the missing shared library.
After that, I delete $HOME/.vscode-server:
rm -rf $HOME/.vscode-server
and tried again connecting using VSCode. It worked!
Hope this can help someone like me, for whom all other options failed.
Issue: while trying to ssh connect to Linux(remote machine) using vscode.
Solution: remove/delete the bin folder inside .vscode-server and then reconnect to the remote machine
In remote server:
remote_name:~$ rm -rf ~/.vscode-server/bin
*reconnect to remote machine*
It turns out that my fish was a obstacle for vscode server.
Then I tried
chsh -s /bin/bash
And works fine.
I worked adding \\ in the path of the .config
I share the steps
Go to .config settings
select configuration
add double \\
Just deleted old host information from ssh settings file and problem solved.
I had faced this issue when I tried to connect to a Linux server from a windows laptop.
It was using the wrong fingerprint.
It worked for me after removing the line related to that server from $HOME/.ssh/known_hosts
I ran into the same issue, it got fixed when I updated the path of the IdentityFile from 'ssh_key' to '~/.ssh/ssh_key' (the entire path I mean) so that the VS code could recognize it.
Restart remote machine worked for me (after trying all the previous answers with no luck).
Giving you the oldest trick of the book:
restart
It worked for me and I laughed hysterically for exactly 57 seconds. Happy reconnecting to the server my dear Coder!
I could not connect to the server, my issue was the remote server was full
check with the command df -h if the disk is full !
Here is an alternative for Remote SSH, pls check my answer at: https://stackoverflow.com/a/68046111/13089935
TLDR:
We can use a web-based VS Code that is installed on the server directly.

Visual Studio Code Remote - SSH with key via KeePass / KeeAgent fails

I am having trouble using the remote-ssh plugin in Visual Studio between machine A and machine B where the key is provided by KeeAgent from a KeePass database on machine A.
Machine A runs on Windows 10 and I have set up the Host (machine B) in Visual Studio Code correctly according to the guide. However, when trying to use the remote feature, I get the following error:
[09:48:32.111] Log Level: 2
[09:48:32.121] remote-ssh#0.51.0
[09:48:32.121] win32 x64
[09:48:32.124] SSH Resolver called for "ssh-remote+XXX.XXX.XXX.XXX", attempt 1
[09:48:32.125] SSH Resolver called for host: XXX.XXX.XXX.XXX
[09:48:32.125] Setting up SSH remote "XXX.XXX.XXX.XXX"
[09:48:32.314] Using commit id "91899dcef7b8110878ea59626991a18c8a6a1b3e" and quality "stable" for server
[09:48:32.317] Install and start server if needed
[09:48:38.141] getPlatformForHost was canceled
[09:48:38.142] Resolver error: Connecting was canceled
[09:48:38.147] ------
where XXX.XXX.XXX.XXX obviously is the correct IP of machine B in my output.
As I mentioned, the SSH key for this machine is provided via KeeAgent and works fine with PuTTy. I am not allowed to store a SSH key in plaintext on machine A, hence the Keepass/KeeAgent solution. I guess this is the Problem, that somehow Visual Studio Code does not work with KeeAgent.
Can I work around this, i.e. by telling VS Code to use plink.exe as SSH client, which works with KeeAgent? Or does VS Code allow the encrypted storage of SSH keys itself, thereby making KeeAgent obsolete? I am new to both VS Code and the remote-ssh plugin, so I'm sorry if my questions have obvious solutions.
Maybe the problem lies elsewhere though. In that case I am thankful for every hint.
Thanks!
Go to Options > KeeAgent, then scroll down to Agent Mode Options and activate Enable agent for Windows OpenSSH (experimental): (default: disabled) Enable an SSH agent socket compatible with the built-in Windows 10 SSH client.

Remote-SSH not finding the agent

I'm trying to get Remote-SSH working with ssh-agent, from Windows 7 desktop to CentOs 7 server.
I'm using ssh, ssh-add and ssh-agent from the Git for windows package. From the cmd prompt, this is all working fine, I can "ssh-add -l" and see the keys, and I can run "ssh " and it runs with no problems and without asking for password:
C:\Users\gnb>"c:\Program Files\Git\usr\bin\ssh-add.exe" -l
4096 SHA256:zg2IR6OlPwCGP8SzcbriXIQjth5zuDc9rbO6uaNPmcU gnb#VDI028-MEL (RSA)
C:\Users\gnb>ssh vdi ls
Desktop
tsclient
wkspace
C:\Users\gnb>
From within VS-Code, I can't get this to work. Running the exact same ssh-add command from within the VS-Code Terminal does not seem to find the agent:
C:\Users\gnb>"c:\Program Files\Git\usr\bin\ssh-add.exe" -l
Could not open a connection to your authentication agent.
The actual remote functionality in VS-Code more or less works, but keeps stopping to ask for passwords.
What's missing here? Why can the vs-code environment not connect to the ssh-agent?
OK, I've had a few more hours playing around with this and I think I understand what's going on.
It only works from cmd if it is the same cmd window that was used to start the agent. Opening a new cmd window then ssh gets the same msg as starting vs-code from the menu - can't find the agent. It appears that the start-ssh-agent script that comes with git/ssh on Win7 is setting some environment variables or some such that the ssh client needs. This does make sense, Unix ssh-agent acts the same way, but I'm clearly not used to thinking about windows apps in those terms.
It also seems the start-ssg-agent script will set the environment variables to point to an existing agent if one is running, else will create a new agent. So a 2 line batch file
start-ssh-agent
code
will reliably start up VS Code with the ssh-agent. If you name the identity file in the ssh config, vs-code will add they key to the agent when required. Otherwise you need to manually add the key to the agent, or fall back to entering the password all the time.
Suspect the better solution is to be on Win10 and use ssh-agent as a service, which should mean VS-code should find the agent when run from a menu. But I can't test that.