How to get vscode-remote-ssh extension connects via git bash in windows? - vscode-remote

I have vs code configured to use the git bash as a terminal in windows 7.
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe"
I have enabled SSH key based authentication to remotely access a host. All this works fine from within the terminal in VS Code.
However, when using the vscode-remote SSH extension to connect to host I get an error because it tries to connect using "The terminal process command 'cmd.exe'" instead of git bash.
I've checked my terminal settings configuration in vs code and it points to git bash.exe
I've used the terminal extension in vs code and it opens a git bash and successfully connects to the host
Is there a setting that I'm missing to force Remote-SSH to use the git bash for the connection?

JerryL's answer lead me to realize, that I can simply set GIT's ssh path c:\Program Files\Git\usr\bin\ssh.exe in the remote.SSH.path setting of VS Code Preferences:
Then it just worked like a charm.
Just for clarity my VS Code version is: 1.40.0-insider (system setup)

I ran into a similar issue trying to get MS VS Code Studio Remote-SSH working with Putty's Pageant. I had Git for Windows installed and in a Git Bash shell, I could ssh and pick up the Pageant keys and no password was needed.
But VS Code Remote-SSH, while using the Git ssh in C:\Program Files\Git\usr\bin\ssh.exe was using Windows 7 cmd.exe shell which didn't talk to Pageant.
What worked for me on Windows 7, VS Code 1.36.1 with (Remote Development 0.15.0, Remote-SSH 0.44.0) and Git for Windows 2.22:
Start Pageant (C:\Program Files\PuTTY\pageant.exe) and Add key.
Start the ssh agent shim (C:\Program Files\Git\cmd\start-ssh-pageant.cmd). This takes care of the communication between Git ssh, which looks for ssh-agent, and Pageant.
Create the SSH_AUTH_SOCK environment variable
Control Panel / System / Advanced Settings / Environment Variables..
User variables for username / New..:
Variable name: SSH_AUTH_SOCK
Variable value: /tmp/.ssh-pageant-username (e.g. /tmp/.ssh-pageant-bill) (Environment Variable assignment screenshot)
Test ssh:
Open a command prompt: Enter set to view the list of Environment Variables. Is the SSH_AUTH_SOCK variable set correctly to something like /tmp/.ssh-pageant-bill?
Try ssh to your host using Git's ssh.exe: c:\Program Files\Git\usr\bin\ssh.exe user#host If this works, then VS Code Remote-SSH should work.
Finally, I added Pageant and start-ssh-pageant.cmd to my Windows 7 Startup so this persists across reboots.
Hope that helps.
Jerry.

I had a similar problem trying to get VS Code Remote use Putty Pageant.
1. Create .bat file somewhere with the following content:
echo OpenSSH
"C:\YOUR_PATH_HERE\PLINK.EXE" -ssh %*
2. Open VS Code settings, type remote ssh path in search and find Remote.SSH: Path settings
3. Past here path to your .bat file
4. Now VS Code Remote will use Pageant correctly.

Related

How edit files with Visual Code remote extension using sudo

The Visual Code remote SSH extension allows editing any remote file in the embedded terminal just using code <filename> which is super useful.
However when opening a file with sudo e.g. sudo code /etc/fstabs it returns
sudo: code: command not found
Is there any way to allow the use of code to any user?
I don't believe this is possible at the time of writing as it would require the underlying node which is running VSCode server to be running with sudo, which it is not.
I have opened a GitHub Issue here.

Running adb shell has no response on Git Bash

Git Bash version is "Git-2.16.2-32-bit".
After installing the Git Bash, and set up the env PATH.
adb.exe has no response when I execute "adb shell".
I can do "adb devices" or "adb push", but adb shell has no response
Please refer below's picture :
KimmyYang#KimmyYang-3020 MINGW64 /d/Git $ env
HOMEPATH=\Users\kimmyyang
MANPATH=/mingw64/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man:
APPDATA=C:\Users\kimmyyang\AppData\Roaming
ProgramW6432=C:\Program Files
HOSTNAME=KimmyYang-3020
SHELL=/usr/bin/bash
TERM=xterm
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
WINDIR=C:\Windows
TMPDIR=/tmp
PUBLIC=C:\Users\Public
OLDPWD=/d
USERDOMAIN=FIHTDC
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
OS=Windows_NT
ALLUSERSPROFILE=C:\ProgramData
windows_tracing_flags=3
windows_tracing_logfile=C:\BVTBin\Tests\installpackage\csilogfile.log
TEMP=/tmp
COMMONPROGRAMFILES=C:\Program Files\Common Files
USERNAME=KimmyYang
PROCESSOR_LEVEL=6
ProgramFiles(x86)=C:\Program Files (x86)
PATH=/c/platform-tools:/c/Users/kimmyyang/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/kimmyyang/bin:/c/Program Files (x86)/Intel/iCLS Client:/c/Program Files/Intel/iCLS Client:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files/PuTTY:/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/c/Python27:/c/Python27/Scripts:/c/Python27/Lib/site-packages:/c/Python27/Lib/site-packages/gensim:/c/Python27/Lib/site-packages/scipy/extra-dll:/c/platform-tools:/usr/bin/vendor_perl:/usr/bin/core_perl
EXEPATH=D:\Git
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
FP_NO_HOST_CHECK=NO
PWD=/d/Git
SYSTEMDRIVE=C:
LANG=zh_TW.UTF-8
VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
USERPROFILE=C:\Users\kimmyyang
PS1=\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u#\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$
LOGONSERVER=\\HC-A01
CommonProgramW6432=C:\Program Files\Common Files
PROCESSOR_ARCHITECTURE=AMD64
LOCALAPPDATA=C:\Users\kimmyyang\AppData\Local
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass
ProgramData=C:\ProgramData
SHLVL=1
HOME=/c/Users/kimmyyang
USERDNSDOMAIN=FIHTDC.COM
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PLINK_PROTOCOL=ssh
HOMEDRIVE=C:
MSYSTEM=MINGW64
COMSPEC=C:\Windows\system32\cmd.exe
TMP=/tmp
SYSTEMROOT=C:\Windows
PRINTER=\\tpe-f01\DingPu-3F
PROCESSOR_REVISION=3c03
PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
ACLOCAL_PATH=/mingw64/share/aclocal:/usr/share/aclocal
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:/share/info:
PROGRAMFILES=C:\Program Files
DISPLAY=needs-to-be-defined
NUMBER_OF_PROCESSORS=4
SESSIONNAME=Console
COMPUTERNAME=KIMMYYANG-3020
_=/usr/bin/env
Why adb shell has no response on Git Bash?
Thank you.
This is an old question, but it's worth pointing out that you are receiving a response while running adb shell, but it's just that the terminal prompt is not visible. You'd be able to issue commands and view the responses just fine, as shown below.
I only used adb.exe in a CMD session, not a bash session.
As detailed here, git bash provides mintty, with a better POSIX compatibility. That does not work with some Windows programs.
If you use a simplified PATH, you still can access most Linux commands directly from a CMD session (without needing the bash)
Just adding to the knowledge base. Git bash on my windows 10 will work doing an adb shell into my oculus quest 2, but there is no prompt or echo of what you time later. Otoh, vs code says hollywood/ and echoes what you type. Haven't tried winpty yet. Iirc, windows bash works also.
you can try : winpty adb shell.Please refer below's picture :
image

Running batch file from network share (vmware shared folder) in cygwin

I'm having some problems with cygwin and a mapped network drive. My setup is kind of convoluted to deal with some limitations with our corporate VPN. I'm running a Windows 10 VM under VMware Fusion with a shared folder from my Mac host which is mapped to a network drive in Windows. The reason is b/c I access a remote Git repo using a VPN connection that leverages a browser plugin that unfortunately is only working from Safari currently. I need to run git commands from the Mac host but the project's build/development environment is Windows. The VPN browser plugin fails to install in any of the browsers under Windows. Hopefully a temporary problem but one I must workaround for now.
From my cygwin environment the mapped drive does not show up under /cygdrive, possibly b/c it's a shared folder with hgfs file system type. I'm able to mount the shared folder but when I try to run a batch file from the cygwin environment I get the following error:
./OpenCommandPrompt.bat
'\\vmware-host\Shared Folders\grant\Projects\lts\Product'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
The system cannot find the path specified.
'setenv.bat' is not recognized as an internal or external command,
operable program or batch file.
'setclasspath.bat' is not recognized as an internal or external
command, operable program or batch file.
C:\Windows>
It doesn't like the UNC path. I'm able to run the command fine from a PowerShell using the mapped drive letter but no luck from cygwin. My desire is to run the VM headless and access the Windows environment over SSH from my host so I'd like to get this working from the cygwin environment if possible. Any suggestions?
I was able to fix my issue by creating a simple script that I execute from my .bash_profile. I basically check for existence of the /cygdrive/h folder and if it doesn't exist I execute the script.
#!/bin/bash
net use H: '\\vmware-host\Shared Folders\share'
I tried to map the drive from Windows but all attempts to do so failed to register the drive mapping under the /cygdrive folder in cygwin. That was the issue I was trying to overcome. Once I had the mapped drive under /cygdrive, I was able to execute all the batch scripts.
To be honest, I'm still not sure why mapping the drive from Windows does not register it cygwin. The reverse is also true: if I execute the net command from the terminal, it does not register in Explorer.

Where and how to create symlink from public/storage to storage/app/public in laravel 5.2 on homestead on window

how to create symlink from public/storage to storage/app/public in homestead on window.
and how do i access my files from browser, so if i visit that image url via browser then it will show that particular image.
actually i'm building an api which accessible from any domain , so i have to return the url of that particular image which is uploaded. so it will be shown of front end.
i'm also saving path to database which is - storage/app/public/image.png . what should i do now..
I'm new to file system so may be i need steps by step instruction.
i will be so thankful for the help
I had the same problem creating a symbolic link from the "public" folder to a location on the "storage" directory.
I tried to use "mklink /j" as well to create the symlink. However, when I "vagrant ssh" to the virtualbox, I found that it did not actually create the link correctly. Attempting to "cd" to the created link would cause an error. Also it wasn't shown as a symlink in the usual linux notation.
To allow the symlink to be created in the virtualBox:
Open "Local Group Policy Editor".
Go to: Computer Configuration | Windows Settings | Security Settings | Local -Policies | User Rights Assignment
Find the "Create symbolic links" policy and add your logged in user to it.
Restart your host windows machine. ssh to your virtualbox. You may need to run "vagrant up" as an Administrator by opening your CMD using "Run as administrator" option.
Go to your "public" folder, and create your symbolic link using the linux "ln -s" command. It should work now.
I was using Windows 10, but the above should be the same for Windows 7.
The "Create symbolic links" policy may be located somewhere slightly different for earlier versions of Windows.
Credit should go to this blog: Symlink support in Windows and Virtualbox
I tried this and it works. Running homestead on VirtualBox on Windows 10:
Open cmd as administrator
Click Start->Run
Type 'cmd', and press ctrl-shift-enter
Select 'yes' from the pop-up window
Type the following command:mklink /D c:\<project_directory>\public\storage "/home/vagrant/<project_directory>/storage/app"
Then the storage/app will be accessible from public/storage in Homestead VM. Note that this is assuming C:\ is shared as /home/vagrant in Homestead VM.
On a MacOS you need to go to your Homestead folder and:
run: vagrant ssh
navigate to your project root folder
run: php artisan storage:link
And you are done.
If you do this without ssh to vagrant then it will not work.

Batch script not doing anything when execute from remote machine using ssh

i'm having a problem while executing batch script from linux machine.
Scenario:
I've a windows machine installed server2008, I need to automate some windows task that executes from linux machine. I've installed cygwin software on windows VM and create a batch script that is running fine from cygwin terminal. i.e cd ~/;./script.bat
Problem:
When I execute the same script from linux machine using ssh it seems works fine and print script executed successfully but when I checked that the task from windows it did nothing.
cat script.bat
#echo off
set sourcePasswd=%1
set destinationPasswd=%2
set destinationProjectName=%3
set user=%4
set xmlPath=C:\cygwin\home\%user%\Duplicate.xml
ECHO Start : Duplication project source for %destinationProjectName%
"C:\Program Files (x86)\Common Files\MySoftware\Duplicate.EXE" -f %xmlPath% -sp %sourcePasswd% -dp %destinationPasswd% -sup -md -dn %destinationProjectName%
ECHO Finish : Duplication project source for %destinationProjectName%
Looks like Leopard hasn't been back since he posted the question or the link to the answer, so I'll be the Point Pimpette tonight and fill in the blank.
The answer below is from the link:
http://cygwin.com/ml/cygwin/2010-07/msg00598.html
It was fixed after doing the following setup :
Open control panel=> Administrative Tools=>Computer
Management=>Services
lookup the sshd service, right
click=>properties=>log on, and check the checkbox for Allow service
to interact with desktop
restart the service.
thanks
Saravana

Resources