cmder icon indicating copy to clipboard operation
cmder copied to clipboard

SSH doesn't work in PowerShell except when powershell.exe launched through CMD

Open audacenoire opened this issue 3 years ago • 15 comments

When I try to launch SSH from PowerShell on a fresh Cmder install I get the following error:


ssh : The term 'ssh' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Yet it works fine if I start up cmd, then launch powershell.exe from there, then run ssh.

audacenoire avatar May 19 '22 02:05 audacenoire

Works for me. What version of cmder?

daxgames avatar May 19 '22 22:05 daxgames

1.3.19, installed from Chocolatey

I'm wondering if not having OpenSSH installed is a part of it, but I've got a whole other issue when I try to use OpenSSH, which is that certain apps that generate a graphical console interface (e.g. mc, raspi-config, mutt) flicker so heavily they're unusable, but in native Cmder ssh they work fine. I'm trying to just use native Cmder ssh.

audacenoire avatar May 19 '22 23:05 audacenoire

Cmder full or mini. Mini does not include ssh.

daxgames avatar May 20 '22 02:05 daxgames

Openssh not installed is not an issue if usingg cmder full.

daxgames avatar May 20 '22 02:05 daxgames

It's the full version.

audacenoire avatar May 20 '22 02:05 audacenoire

Maybe the tab being used has some configuration that replaces the %PATH% variable, so that the ssh directory is no longer in the system path.

chrisant996 avatar May 20 '22 03:05 chrisant996

So I ran Get-Command through the cmd powershell and got this output:

CommandType: Application
Name: ssh.exe
Version: 0.0.0.0
Source: C:\Program Files\Git\usr\bin\ssh.exe

What I'm getting from this is that the PowerShell being invoked from ConEmu isn't registering the path, but it is for cmd, and based on my examination of the Cmder included cmd shell vs. the ConEmu default cmd shell, may have something to do with %ConEmuDir%\..\init.bat not being invoked by the PowerShell task.

audacenoire avatar May 20 '22 03:05 audacenoire

My bad. I've been following this from my phone and I misread it. I have duplicated the issue snd will try and resolve it.

daxgames avatar May 20 '22 12:05 daxgames

Have you tried the latest unreleased build?

https://ci.appveyor.com/api/buildjobs/xhdkfq5ic63jamvv/artifacts/build%2Fcmder.zip

daxgames avatar May 20 '22 12:05 daxgames

Trying it now, no joy so far.

audacenoire avatar May 20 '22 13:05 audacenoire

I seem to have made a workaround by adding set PATH=%ProgramFiles%\Git\usr\bin;%PATH%

to the environment paths.

audacenoire avatar May 21 '22 06:05 audacenoire

That's not a fix. Git is already there in %cmder_root%/vendor/git-for-windows.

You could have added folders that Cmder is supposed to be finding and adding but is not to the path.

The fix is to fix cmders init scripts so they do this. I will work on it as time allows and let you know.

Edit: See my post 2 down from here. THis is fixed in the unreleased code.

daxgames avatar May 21 '22 11:05 daxgames

I just realized this but I think Powershell init scripts are different than cmd init scripts and may not add the folders that contain ssh and other utilities to the path. I need to confirm this.

Edit: The above statement is incorrect

daxgames avatar May 21 '22 12:05 daxgames

I just downloaded the unreleased build and it seems to work fine. In the screenshot below I launched Cmder which started a cmd.exe based Cmder session. I then used the image to launch a Powershell.exe based Cmder session to the right of the initial session. I did not start Powershell from the Cmder cmd.exe shell.

image

daxgames avatar May 21 '22 21:05 daxgames

Hmm. I wonder if it's some way my Windows is set up.

audacenoire avatar May 22 '22 21:05 audacenoire