Remote SSH on VS Code in WSL2 password prompt - visual-studio-code

I am trying to connect to my server via SSH in VS Code for Ubuntu WSL2. However, whenever I make a connection, it is using the windows SSH instead of my Ubuntu WSL2. Is there anyway to start the remote SSH terminal in Ubuntu instead of the default Windows command prompt?
[10:14:37.201] Log Level: 2
[10:14:37.205] remote-ssh#0.62.0
[10:14:37.205] win32 x64
[10:14:37.208] "remote.SSH.sshPath": /usr/bin/ssh
[10:14:37.208] "remote.SSH.sshConfigurationFile": ~/.ssh/config
[10:14:37.245] Checking ssh with "/usr/bin/ssh -V"
[10:14:37.251] Got error from ssh: spawn /usr/bin/ssh ENOENT
[10:14:37.251] The specified path /usr/bin/ssh is not a valid SSH binary
[10:14:37.252] Checking ssh with "ssh -V"
[10:14:37.296] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[10:14:37.300] Using SSH config file "~/.ssh/config"
[10:14:37.300] Running script with connection command: ssh -T -D 60054 -F "~/.ssh/config" "test-wsl" bash
[10:14:37.303] Terminal shell path: C:\WINDOWS\System32\cmd.exe

If anyone else ran into the same problem as me, it seems that remote server in VS Code is picking up cmd as the default terminal, so I had to copy my private keys over to /mnt/c/Users/{user}/.ssh directory in order to get ssh key based authentication to work. It would be better if I could change the default shell to C:\WINDOWS\System32\bash.exe.

Related

linux telnet server in.telnetd options telnet command line

linux telnet server in.telnetd options telnet command line
i try to use in.telnetd in centos linux command line to set some options
this is tool usage
Usage: telnetd [-debug|-debug6] [-D (options|report|exercise|netdata|ptydata)]
[-h] [-L login_program] [-n] [-N] [port]
on tool documents documentation -E can Disables encryption support negotiation
how i can use command to disable it or change it

Error: wsl.exe exited with code 4294967295 on Installing Rancher Desktop

I am getting the below error when installing the latest stable Rancher Desktop in my Virtual Machine.
Could someone please help?
Error:
Error: wsl.exe exited with code 4294967295
Command:
wsl --distribution rancher-desktop --exec mkdir -p /mnt/wsl/rancher-desktop/run/data
Logs:
2022-02-02T09:58:39.490Z: Running command wsl --distribution
rancher-desktop --exec wslpath -a -u
C:\Users\VIVEK~1.NUN\AppData\Local\Temp\rd-distro-gGd3SG\distro.tar...
2022-02-02T09:58:40.641Z: Running command wsl --distribution
rancher-desktop --exec tar -cf
/mnt/c/Users/VIVEK~1.NUN/AppData/Local/Temp/rd-distro-gGd3SG/distro.tar
-C / /bin/busybox /bin/mount /bin/sh /lib /etc/wsl.conf /etc/passwd /etc/rancher /var/lib... 2022-02-02T09:58:42.628Z: Running command wsl
--import rancher-desktop-data C:\Users\Vivek.Nuna\AppData\Local\rancher-desktop\distro-data
C:\Users\VIVEK~1.NUN\AppData\Local\Temp\rd-distro-gGd3SG\distro.tar
--version 2... 2022-02-02T09:58:44.025Z: Running command wsl --distribution rancher-desktop-data --exec /bin/busybox [ ! -d /etc/rancher ]... 2022-02-02T09:58:44.025Z: Running command wsl
--distribution rancher-desktop-data --exec /bin/busybox [ ! -d /var/lib ]... 2022-02-02T10:03:54.533Z: Running command wsl
--terminate rancher-desktop... 2022-02-02T10:03:54.534Z: Running command wsl --terminate rancher-desktop-data...
2022-02-02T10:03:54.971Z: Running command wsl --distribution
rancher-desktop --exec mkdir -p /mnt/wsl/rancher-desktop/run/data...
2022-02-02T10:04:03.418Z: WSL: executing: mkdir -p
/mnt/wsl/rancher-desktop/run/data: Error: wsl.exe exited with code
4294967295
I met the same issue in Windows 10.
Below solution helped me:
1. Quit Rancher Desktop
2. Run below command in Windows command line:
wsl --update
3. After update completed, open Rancher Desktop again.
Rancher Desktop works well now.
After completed installing Rancher desktop, you can use the docker and kubectl commands in Windows command line successfully.
References:
Error: wsl.exe exited with code 4294967295 #1328 - github
I resolved the issue by following steps 4 and 5 here:
https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package
I found this answer by looking in %USERPROFILE%\AppData\Local\rancher-desktop\logs\wsl-exec.log which revealed:
"WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel"
Right click Rancher Desktop Icon in Task bar, And Select "Quit Rancher Desktop"
Done below in cmd.exe or powershell
> wsl --unregister rancher-desktop
> wsl --unregister rancher-desktop-data
In my case :
1.The Virtualization in BIOS was not enabled
2.You can check yours in Task manager > Performance Tab > CPU Section
Task Manager Picture
Once i enabled from BIOS it started working.

Deleted Shell on WSL and Cannot Access WSL

During an attempt to remove zsh from Ubuntu running on WSL, I ran:
sudo apt-get --purge remove zsh
Foolishly, I did not reset my default shell, so I cannot access WSL. The windows flashes open and then closes.
I can see from powershell that all of my files in WSL are still available, but I do not know how to reset the default shell in WSL from Powershell.
How can I reinstall bash or zsh from Powershell?
So I figured this out. From an 'elevated' powershell I executed the following commands:
cd \wsl$<distro name>
wsl -e bash
sudo vipw
From there, I went to /etc/passwd and changed the shell on my username to bash.

Start ssh-agent when windows boots along with ssh passphrase

I have a private Github repo, and I generated the SSH keys using windows.
I am trying to launch ssh-agent when my windows server starts, I can have the following command..
start "" "%PROGRAMFILES%\Git\bin\sh.exe" --login -i
but the problem with this is...I would need to enter the passphrase for my SSH key everytime i reboot.
I am working with a github repo, where whenever we commit a change then it triggers the GIT PULL on the server (using webhooks).
Anyway I can automate this?
You could make sure your .profile (called by sh --login -i) includes a call to ssh-agent with a file:
cat passfile | ssh-add -p keyfile
That way, every time the shell starts, the agent includes your key with its passphrase.

Automation of Cygwin configuration with PowerShell

I have installed Cygwin using PowerShell scripting.
I am doing the following step manually:
Running a new cygwin bash shell (after the edit of cygwin.bat) and enter:
mount --change-cygdrive-prefix /
chmod +r /etc/passwd /etc/group
chmod 755 /var
Start Cygwin bash shell and run ssh-host-config. Answer yes to all the key generation questions.
Is it possible to automate these things in PowerShell scripts, like installing Cygwin, then doing steps 1 and 2 in a single shot?
Use this command:
bash.exe ssh-host-config --yes -u "Cygwinuser" -c "binmode ntsec tty" -w "pwd#123"
cygrunsrv -S sshd
Later go to services.msc to check if the service is running or not