Bug 1294401

Summary: rhc ssh <appname> does not respect PATH env variable, nor the --ssh PATH option
Product: OpenShift Online Reporter: belltown <sea.av80r>
Component: ocAssignee: Sally <somalley>
Status: CLOSED WONTFIX QA Contact: Wei Sun <wsun>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 2.xCC: aaron.hurui, aos-bugs, jokerman, mmccomas, somalley, yanpzhan
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1307174 1310813 (view as bug list) Environment:
Last Closed: 2017-05-31 18:22:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1307174, 1310813    
Attachments:
Description Flags
rhc-1.38.4.gem
none
updated rhc-1.38.4.gem none

Description belltown 2015-12-28 03:28:37 UTC
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 13:54:47 UTC
face the same issue, hope a solution

Comment 2 Yanping Zhang 2016-02-01 11:11:54 UTC
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 11:35:37 UTC
Created attachment 1120074 [details]
rhc-1.38.4.gem

please use the attached gemfile for testing, thanks.

Comment 4 Yanping Zhang 2016-02-02 05:41:33 UTC
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.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.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.com.cn ...
4.2 Ssh using git bash, it succeeds:
$rhc ssh php1 --ssh "C:\Users\openshift\ssh.exe"
Connecting to 56af35d735348f0625000668.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 15:27:03 UTC
Comment on attachment 1120074 [details]
rhc-1.38.4.gem

Please use the updated .gem file

Comment 6 Sally 2016-02-02 15:28:54 UTC
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 15:37:03 UTC
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 11:10:02 UTC
@Sally
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 18:55:46 UTC
@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 07:58:03 UTC
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 18:22:11 UTC
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.