1

I'm using Windows7 desktop and installed ssh to access this Windows7 desktop remotely.

In Windows7 environment, I use ConEmu or git bash, which makes Window7env similar with Linux.

The Problem is that when I access this Windows 7 via ssh, it shows cmd pane.

Is there any way to show git bash or ConEmu interface instead of cmd when accessing via ssh?

user3595632
  • 5,380
  • 10
  • 55
  • 111

1 Answers1

0

You should at least be able to call a bash (simply by typing bash) from the CMD you see through your ssh session.
If you cannot, it means the PATH given you by your remote ssh session does not include C:\path\to\Git\bin.
In that case, copy C:\path\to\Git\bin\bash.exe to C:\Windows\System32 that won't work, as commented by Maximus).

As I mention, look for an sshd_config file on your server, and add the right path as described here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I follow your instruction and `bash` command works in my remote shell, but the interface doesn't change. In short, when I access via `ssh` and type `bash`, nothing has happend... `ls` doesn't work.. – user3595632 Jan 12 '18 at 06:20
  • @user3595632 can you, in your ssh session, type `where bash` to confirm it at least find `bash.exe`? Also what `set PATH` return (when typed in your ssh session). – VonC Jan 12 '18 at 07:33
  • `where bash` -> `C:\Windows\System32\bash.exe`. And `set PATH` -> Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsP owerShell\v1.0\; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC – user3595632 Jan 12 '18 at 08:34
  • @user3595632 Any chance you can modify your ssh daemon in order to include C:\path\to\git\usr\bin in your PATH as offered by ssh? – VonC Jan 12 '18 at 08:36
  • Sorry but cannot understand what u said. What is the meaning of "modify your ssh daemon"? and what is `C:\path\to\git\usr\bin`? Does git has bin folder? – user3595632 Jan 12 '18 at 08:44
  • @user3595632 When you access Windows7 through ssh, that means you have an ssh daemon, a listener, on said Windows 7: which SSH program are you using on that server to listen to ssh queries? – VonC Jan 12 '18 at 08:52
  • @user3595632 And yes, git has a bin folder: on your Windows 7 (not through ssh but directly no it), type `where git` – VonC Jan 12 '18 at 08:53
  • I followed this instruction : https://winscp.net/eng/docs/guide_windows_openssh_server. Please tell me if this one is not good ssh daemon :) and really appreciate your all comments !! – user3595632 Jan 12 '18 at 10:43
  • @user3595632 look for an sshd_config file on your server, for you to add the right path: https://unix.stackexchange.com/a/332534/7490 – VonC Jan 12 '18 at 15:09
  • @user3595632 Windows 7 installation can't have `bash.exe` in the `system32` folder. That is some third-party application which may even harm your system. – Maximus Jan 12 '18 at 23:12
  • @Maximus Good point. I have edited the answer to make it clearer this is not a good option. – VonC Jan 12 '18 at 23:15
  • @Maximus: is there something special about `bash.exe` that makes it not work in `\windows\system32`? I can put 3rd party programs in there and have them work – Michael Burr Jan 12 '18 at 23:39
  • @MichaelBurr You can put 64-bits third-party in there, not 32 (https://superuser.com/a/933335/141). And if the OP has installed a 32-bits Git for Windows... that wouldn't work. – VonC Jan 12 '18 at 23:50
  • So what is the conclusion? I have added git's `bin` path to system `PATH` and I also found out `sshd-config` but it is empty. There is no directory path, called `~/.ssh`. It still doesn't work. – user3595632 Jan 13 '18 at 05:36
  • @user3595632 That is expected (unless you have the very latest Windows 10 Creator 1709, in which case openssh is already installed: https://poweruser.blog/enabling-the-hidden-openssh-server-in-windows-10-fall-creators-update-1709-and-why-its-great-51c9d06db8df). But if not, check http://diddy.boot-land.net/ssh/files/ssh_openssh.htm: Did you found sshd_config in `C:\Program Files\OpenSSH\etc\sshd_config`? That is where you must put the line `PermitUserEnvironment yes`. THen restart the ssh daemon, and try for testing: ssh yourServer "export PATH=$PATH:/c/path/to/git/bin; echo $PATH; which bash" – VonC Jan 13 '18 at 06:57
  • @VonC I opened `sshd_config` in and there are a lot of contents inside. changed `PermitUserEnvironment` from `no` to `yes` and restart this window server. You said after I access my window server by ssh and type `export PATH=$PATH:/c/path/to/git/bin; ` right? But when I accessed via `ssh`, its interface is `cmd` so I can not set `PATH` variable since this is `cmd`... – user3595632 Jan 13 '18 at 07:21
  • @user3595632 if it is a CMD (and not a shell), then type: `set PATH=%PATH%;C:\path\to\git\bin&& echo %PATH%&& where bash`: note the lack of space between a command and `&&`. That is intentional. – VonC Jan 13 '18 at 07:25
  • @user3595632 Actually, the command to type should be: `cmd /v /c "set PATH=%PATH%;C:\path\to\git\bin&& echo !PATH!&& where bash"` Note the `!PATH!` syntax. – VonC Jan 13 '18 at 07:27
  • Still doesn't work : `chois@CHOIS-PC C:\Users\Chois>cmd /v /c "set PATH=%PATH%;C:\Program Files\Git\mingw64\bin&& echo !PATH!&& where bash C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Sublime Tex t 3;C:\Users\Chois\Miniconda3;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\cmd;;C:\Program Files\Git\mingw64\bin\;C:\Pr ogram Files\Git\mingw64\bin` 정보: 제공된 패턴에 해당되는 파일을 찾지 못했습니다. – user3595632 Jan 13 '18 at 07:31
  • Error in English : can not find file for given pattern. – user3595632 Jan 13 '18 at 07:32
  • @user3595632 If my korean is not too rusty, that was "Info: The file corresponding to the provided pattern was not found." I wonder what part of the line trigger this? Can you try: `echo %PATH%` just to see if this command works, and what your default PATH looks like? – VonC Jan 13 '18 at 07:34
  • `chois@CHOIS-PC C:\Users\Chois>echo %PATH% C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Sublime Tex t 3;C:\Users\Chois\Miniconda3;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\cmd;` – user3595632 Jan 13 '18 at 07:50
  • @user3595632 So... `C:\Program Files\Git\mingw64\bin` is already part of your PATH. Can you try, in your ssh session, `where bash`? – VonC Jan 13 '18 at 07:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163093/discussion-between-vonc-and-user3595632). – VonC Jan 13 '18 at 07:53