Bug 1294401 - rhc ssh <appname> does not respect PATH env variable, nor the --ssh PATH option
rhc ssh <appname> does not respect PATH env variable, nor the --ssh PATH option
Product: OpenShift Online
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
x86_64 Windows
unspecified Severity medium
: ---
: ---
Assigned To: Sally
Wei Sun
Depends On:
Blocks: 1307174 1310813
  Show dependency treegraph
Reported: 2015-12-27 22:28 EST by belltown
Modified: 2017-05-31 14:22 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1307174 1310813 (view as bug list)
Last Closed: 2017-05-31 14:22:11 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
rhc-1.38.4.gem (242.50 KB, application/x-tar)
2016-02-01 06:35 EST, Sally
no flags Details
updated rhc-1.38.4.gem (242.50 KB, application/x-tar)
2016-02-02 10:28 EST, Sally
no flags Details

  None (edit)
Description belltown 2015-12-27 22:28:37 EST
Description of problem:

- Running Windows 10 Home Edition

- Installed Ruby from http://rubyinstaller.org/downloads/
    (ruby 2.1.7p400 (2015-08-18 revision 51632) [i386-mingw32]

- Installed Git from https://git-for-windows.github.io/
    (git version 2.6.4.windows.1)

- Installed rhc using: gem install rhc
    (rhc (1.38.4))

- Ran rhc setup. All steps appeared to complete successfully

- Attempted to connect via ssh using: rhc ssh <appname>

- Received the following message:
    No system SSH available. Please use the --ssh option to specify the path to your SSH executable, or install SSH. We
recommend this free application: Git for Windows - a basic git command line and GUI client http://msysgit.github.io/.

- Verified that set PATH included: C:\Program Files\Git\usr\bin

- Verified that C:\Program Files\Git\usr\bin contained ssh.exe

- Attempted to connect via ssh using: 
    rhc ssh <appname> --ssh "C:\Program Files\Git\usr\bin\ssh.exe"

- Received the following messages:
C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/lib/rhc/commands/ssh.rb:49:in `exec': No such file or directory - C:\Program (Errno::ENOENT)
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/lib/rhc/commands/ssh.rb:49:in `run'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/lib/rhc/commands.rb:294:in `execute'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/lib/rhc/commands.rb:285:in `block (3 levels) in to_commander'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/commander-4.2.1/lib/commander/command.rb:180:in `call'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/commander-4.2.1/lib/commander/command.rb:155:in `run'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:421:in `run_active_command'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/lib/rhc/command_runner.rb:72:in `run!'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:in `run!'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/lib/rhc/cli.rb:37:in `start'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rhc-1.38.4/bin/rhc:20:in `<top (required)>'
        from C:/Ruby21/bin/rhc:23:in `load'
        from C:/Ruby21/bin/rhc:23:in `<main>'

- Copied ssh.exe from C:\Program Files\Git\usr\bin to C:\Program Files\Git\bin

- Attempted to connect via ssh using: rhc ssh <appname>

- SUCCESS: Finally managed to connect successfully!

Version-Release number of selected component (if applicable):
    rhc (1.38.4)

How reproducible:
    Consistently reproducible

Steps to Reproduce:
    (see Description of problem)

Actual results:
    Even with the PATH environment variable including the folder containing ssh.exe, the rhc ssh command failed.

    Even when the --ssh option was applied to the rhc ssh command to specify the path to the ssh.exe file, the command failed.

    The only way to get the rhc ssh command to work was to copy the ssh.exe file from the C:\Program Files\Git\usr\bin folder to the C:\Program Files\Git\bin folder.

Expected results:
    Should not have to copy ssh.exe to another folder to get the rhc ssh command to work

Additional info:
    Possible solutions:
    1. Include C:\Program Files\Git\usr\bin in the search path.
    2. Include the PATH folders in the search path.
    3. Fix whatever is causing the --ssh option to fail.
    4. The no system SSH message recommends installing Git from http://msysgit.github.io/, which according to its Github repo is now obsolete, having been superseded by https://git-for-windows.github.io/.
Comment 1 aaron.hurui 2016-01-21 08:54:47 EST
face the same issue, hope a solution
Comment 2 Yanping Zhang 2016-02-01 06:11:54 EST
Tested with rhc-1.38.6 from the libra-rhel-6-stage/client/gems/, the issue seems still there. Where can I get the rhc gem file that contains the fix for the bug?
Comment 3 Sally 2016-02-01 06:35 EST
Created attachment 1120074 [details]

please use the attached gemfile for testing, thanks.
Comment 4 Yanping Zhang 2016-02-02 00:41:33 EST
1.Install rhc-1.38.4.gem from attachment on win10
2.Login openshift server:
C:\Users\openshift>rhc setup --server=<serverip>
3.Ssh into app. Now we can ssh into app with default ssh successfully:
3.1 Ssh using Win cmd or ruby bash:
C:\Users\openshift>rhc ssh php1
Connecting to 56af35d735348f0625000668@php1-domzyp.ose-22.com.cn ...
[php1-domzyp.ose-22.com.cn 56af35d735348f0625000668]\>ls
app-deployments app-root git php
[php1-domzyp.ose-22.com.cn 56af35d735348f0625000668]\>exit
Connection to php1-domzyp.ose-22.com.cn closed
3.2 Ssh using git bash:
$rhc ssh php1 
Connecting to 56af35d735348f0625000668@php1-domzyp.ose-22.com.cn ...
[php1-domzyp.ose-22.com.cn 56af35d735348f0625000668]\>

4.Ssh into app with --ssh option
4.1 Ssh using Win cmd or ruby bash,it aborts when connecting:
C:\Users\openshift>rhc ssh php1 --ssh "C:\Users\openshift\ssh.exe"
Connecting to 56af35d735348f0625000668@php1-domzyp.ose-22.com.cn ...
4.2 Ssh using git bash, it succeeds:
$rhc ssh php1 --ssh "C:\Users\openshift\ssh.exe"
Connecting to 56af35d735348f0625000668@php1-domzyp.ose-22.com.cn ...
[php1-domzyp.ose-22.com.cn 56af35d735348f0625000668]\>ls

From the step 4.1, there is issue when using --ssh option in ruby bash, Pls help to check. Others works well.
Comment 5 Sally 2016-02-02 10:27:03 EST
Comment on attachment 1120074 [details]

Please use the updated .gem file
Comment 6 Sally 2016-02-02 10:28 EST
Created attachment 1120475 [details]
updated rhc-1.38.4.gem

Please re-test using the attached .gem build from the master branch.  Thanks.
Comment 7 Sally 2016-02-02 10:37:03 EST
QA: Please re-test.  I followed your steps from Comment 4 and everything seems to work on my end.  Did you make a new directory 'openshift' and cp 'ssh.exe' there?  I put a cp of 'ssh.exe' in 'C:\Users\.openshift' and gave that path to ssh cmd:

(From C:\Users\root\rhc directory):

rhc ssh --ssh ../.openshift/ssh.exe testapp

and I was able to ssh in no problems. I did this from Power shell, Ruby cmd prompt and Git Bash.  Thank you for re-testing!
Comment 8 Yanping Zhang 2016-02-03 06:10:02 EST
I made a new directory such as testdir, and cp ssh.exe into the directory, then rhc ssh --ssh "C:\testdir\ssh.exe" seperately in ruby cmd/win cmd/git bash. Only succeeded in git bash. Same results when I cp "ssh.exe" into .openshift directory and used ../.openshift/ssh.exe path.

Another discovery, if the --ssh using the ssh.exe under Git: rhc ssh app --ssh "<Gitpath>\usr\bin\ssh.exe",it can succeed in all bash:ruby cmd/win cmd/git bash

Pls check again, here is my system info:
Ruby version 2.1.7p400
Windows 10
git 2.7.0
Comment 9 Sally 2016-02-04 13:55:46 EST
@Yanping, thanks for the info!  What's happening is git for Windows (msysgit's) ssh.exe is not meant to be run outside of the Git env.  It needs several msys*.dll files to run.  The behavior we are seeing is expected.  Users may use putty.exe instead, for example, but so long as they are using msysgit's ssh.exe it has to a) be run from Git Bash OR b) be in the Git env

The 'rhc ssh --ssh <path to ssh.exe> <app>' is actually working fine, it is locating and running the ssh.exe file.  The program can't find several msys*.dll files if the ssh.exe is in a place outside of Git env so it doesn't fully execute.  We can expect that users would not move ssh.exe somewhere wacky AND try to run rhc ssh --ssh from outside of Git Bash.  

Users can (and probably do) place the ssh.exe file in a custom location and run the cmd 'rhc ssh --ssh <path to ssh.exe> <app>' successfully IF they are running from Git Bash, bc Git Bash knows where the necessary 'msys*.dll' files are.
Comment 10 Yanping Zhang 2016-02-15 02:58:03 EST
Since the "rhc ssh --ssh <path to ssh.exe> appname" works in Git Bash or in the Git env by design according to comment 8 and comment 9. So move the bug to verified.
Comment 11 Eric Paris 2017-05-31 14:22:11 EDT
We apologize, however, we do not plan to address this report at this time. The majority of our active development is for the v3 version of OpenShift. If you would like for Red Hat to reconsider this decision, please reach out to your support representative. We are very sorry for any inconvenience this may cause.

Note You need to log in before you can comment on or make changes to this bug.