Bug 1149016 - Putty error when trying to SSH into Openshift app using the 'rhc' command on windows
Summary: Putty error when trying to SSH into Openshift app using the 'rhc' command on ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: oc
Version: 2.x
Hardware: x86_64
OS: Windows
unspecified
high
Target Milestone: ---
: ---
Assignee: Fabiano Franz
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-02 23:18 UTC by fatfantasma
Modified: 2015-05-15 02:29 UTC (History)
10 users (show)

Fixed In Version: fork_ami_bug_1149016_1263
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-18 16:51:39 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description fatfantasma 2014-10-02 23:18:19 UTC
I am trying to ssh (from windows) into my Openshift app using the 'rhc' command

rhc app-ssh <app name>
I have followed the Openshift instruction here:

https://www.openshift.com/forums/openshift/how-to-rhc-app-ssh-command

Putty is returning the error "Putty Command Line Error: unknown option "-V" and then fails. My google searches indicate putty has a "-v" (lowercase) option for turning on Verbose. I'm not sure if it's one in the same.

If I use the Putty GUI everything works fine. I would like to figure out how to ssh into my openshift app using the command line.

How do I ssh into my openshift app using the 'rhc' command on windows?

Comment 1 Fabiano Franz 2014-10-03 15:37:21 UTC
Please provide the following information:

- Windows version
- Which shell tool are you using (pure cmd.exe, Git BASH, Cygwin, etc)
- The result of running "path" in the command line
- The result of running "ruby -v" in the command line
- List the files you have in "C:\Documents and Settings\<username>\.ssh\" or "C:\Users\<username>\.ssh"

Comment 2 fatfantasma 2014-10-03 21:18:29 UTC
- Windows version
Windows 7x64

- Which shell tool are you using (pure cmd.exe, Git BASH, Cygwin, etc)
pure windows cmd.exe

- The result of running "path" in the command line
PATH=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Ruby200-x64\bin;C
:\Python33\;C:\Python33\scripts;C:\Windows\system32;C:\Windows;C:\Windows\System
32\Wbem;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x
86)\FileBot\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\Win
dowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files\Mercurial\;
C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\PuTTY;c:\slime
rjs-0.9.2


- The result of running "ruby -v" in the command line
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]


- List the files you have in "C:\Documents and Settings\<username>\.ssh\" or "C:\Users\<username>\.ssh"

id_rsa
id_rsa.ppk
id_rsa.pub
known_hosts
Puttyppk_converted_to_openssh


I my Putty folder :C:\Program Files (x86)\PuTTY
putty.exe and ssh.exe are the same file.


FYI.
I just tried using the below Git Bash shell command and it worked.  So the problem seems to be focused on the windows cmd.exe shell.
rhc ssh-app <app name>

Comment 3 Fabiano Franz 2014-10-15 21:17:54 UTC
Fixed in:

https://github.com/openshift/rhc/pull/654

This pull request introduces the following improvements:

On Windows, rhc will try its best to auto-discover ssh and git executables available across the system, even if they are not in the system PATH. 

The following tools will be searched for: ssh.exe tool from msysgit, plink.exe from PuTTY and putty.exe from PuTTY. 

A few locations where these tools will be searched:

PATH
C:\Program Files\Git\bin 
C:\Program Files (x86)\Git\bin 
C:\Program Files\PuTTY
C:\Program Files (x86)\PuTTY
C:\Git\bin 
C:\PuTTY
C:\ 

If the Windows installation has more drives (D:, E:, etc) they will also be searched, on the same locations.

The --ssh flag can still be used if other ssh tools are preferred over the ones rhc will search for. This flag now supports path with spaces between commas (e.g. --ssh "C:\Program Files\MySshTool\ssh.exe".

It's important to mention that *msysgit is preferred over PuTTY* because it handles SSH keys in standard formats, while PuTTY uses it's own *.ppk format.

Comment 4 Fabiano Franz 2014-10-16 16:44:18 UTC
Use fork_ami_bug_1149016_1262.

Comment 5 DeShuai Ma 2014-10-17 07:26:55 UTC
1.In the path "C:\Program Files (x86)\Git\bin" there is ssh.exe
2.In the path "C:\" there is putty.exe
3.Use the command to ssh (from windows) into my Openshift app
rhc app-ssh <app name>
execute result:
Putty is showing the error tip window "Putty Command Line Error: unknown option -V". Then click twice the button "ok" , we can ssh into the app successfully.

4.Remove the putty.exe from the path "C:\", execute the "rhc app-ssh <app name>" again. we can ssh into the app successfully and there is no error tip window.

5.Execute the command "putty.exe -V" in windows cmd terminal.It also show the error window "Putty Command Line Error: unknown option -V".

There is an error option "-V" send to putty.exe when use rhc command to load putty.exe.

Comment 6 Fabiano Franz 2014-10-17 16:54:43 UTC
Fixed in fork_ami_bug_1149016_1263

Comment 7 DeShuai Ma 2014-10-21 02:25:30 UTC
1、Delete or rename the ssh.exe
2、Use command the "rhc app-ssh <app name> --ssh "putty.exe -i key_file.ppk""to connect the app. or use pageant.exe tool to add the putty key_file and then use command "rhc app-ssh <app name>" to connect the app.
3、Connect the app successfully.

Comment 8 DeShuai Ma 2014-10-21 02:47:53 UTC
(In reply to madeshuai from comment #7)
> 1、Delete or rename the ssh.exe
> 2、Use command the "rhc app-ssh <app name> --ssh "putty.exe -i
> key_file.ppk""to connect the app. or use pageant.exe tool to add the putty
> key_file and then use command "rhc app-ssh <app name>" to connect the app.
> 3、Connect the app successfully.

Additional:
rhc version  : 1.31.3(build from source code on server fork_ami_bug_1149016_1263)
online server: fork_ami_bug_1149016_1263

Comment 10 Josep 'Pep' Turro Mauri 2014-11-25 11:55:51 UTC
This change of adding quotes to the ssh command:

https://github.com/openshift/rhc/commit/a9bd6168abfb8e0cd7057e87111a0edc2a84223f#diff-6bb233c6bcab1f993ce51cdf1cd4cbdeL512

breaks things, at least in a non-windows environment:

$ rhc -d snapshot save --ssh 'ssh -v'  21node
[...]
DEBUG: "ssh -v" 54735971e659c5985e000002.example.com 'snapshot' > 21node.tar.gz
Pulling down a snapshot of application '21node' to 21node.tar.gz ... sh: ssh -v: command not found

$ rhc -d ssh --ssh 'ssh -v' 21node
[...]
Connecting to 54735971e659c5985e000002.example.com ...
DEBUG: Using user specified SSH: ssh -v
DEBUG: Invoking Kernel.exec with ["ssh -v", "-vvv", "54735971e659c5985e000002.example.com"]
/home/pep/.gem/ruby/gems/rhc-1.32.2/lib/rhc/commands/ssh.rb:45:in `exec': No such file or directory - ssh -v (Errno::ENOENT)
	from /home/pep/.gem/ruby/gems/rhc-1.32.2/lib/rhc/commands/ssh.rb:45:in `run'
        [...]

Comment 11 Fabiano Franz 2014-11-27 18:48:47 UTC
Fixed in https://github.com/openshift/rhc/pull/661

Comment 12 openshift-github-bot 2014-11-27 19:44:54 UTC
Commit pushed to master at https://github.com/openshift/rhc

https://github.com/openshift/rhc/commit/81a6e5ada0d72e5e020bda14c3622ed52f233f60
Bug 1149016 - fixes ssh path with commas

Comment 13 DeShuai Ma 2014-11-28 10:34:32 UTC
Version-Release number of selected component (if applicable):
rhc version  : 1.33.1(build from source code on server devenv_5325)
online server: devenv_5325
the client is linux env.

steps to Reproduce:
1、create a app on the server
# rhc app-create -a app1 php-5.3
2、use "-d" to ssh a app. can connect the app successfully. But when input some command in the terminal, it print lots of info, and can't input normal.

$ rhc -d ssh --ssh 'ssh -v' app1

[app1-eveusb.dev.rhcloud.com 54786f62fd0bc76401000024]\> debug3: Wrote 48 bytes for a total of 3021
jdebug3: Wrote 48 bytes for a total of 3069
debug3: Wrote 48 bytes for a total of 3117
fdebug3: Wrote 48 bytes for a total of 3165
jdebug3: Wrote 48 bytes for a total of 3213
fdebug3: Wrote 48 bytes for a total of 3261
jdebug3: Wrote 48 bytes for a total of 3309
fdebug3: Wrote 48 bytes for a total of 3357
jdebug3: Wrote 48 bytes for a total of 3405
jjdebug3: Wrote 48 bytes for a total of 3453
debug3: Wrote 48 bytes for a total of 3501
debug3: Wrote 48 bytes for a total of 3549
debug3: Wrote 48 bytes for a total of 3597
debug3: Wrote 48 bytes for a total of 3645
debug3: Wrote 48 bytes for a total of 3693
debug3: Wrote 48 bytes for a total of 3741
debug3: Wrote 48 bytes for a total of 3789
jdebug3: Wrote 48 bytes for a total of 3837
jdebug3: Wrote 48 bytes for a total of 3885
jjjjjjjjdebug3: Wrote 48 bytes for a total of 3933
debug3: Wrote 48 bytes for a total of 3981
jjdebug3: Wrote 48 bytes for a total of 4029
ldebug3: Wrote 48 bytes for a total of 4077
fdebug3: Wrote 48 bytes for a total of 4125
fdebug3: Wrote 48 bytes for a total of 4173
debug3: Wrote 48 bytes for a total of 4221
kdebug3: Wrote 48 bytes for a total of 4269
fk

Comment 14 Fabiano Franz 2014-11-28 14:31:35 UTC
Unable to reproduce, I got similar debug messages when connecting but I was able to use it normally after connecting. If you still see the issue please provide more info.

Notice that "--ssh 'ssh -v'" was used to test the ssh flag with blank spaces, but it's actually redundant since the debug flag "rhc -d" will already put ssh on debug mode through "-vvv".

Comment 17 Fabiano Franz 2014-12-01 16:26:53 UTC
Fixed in https://github.com/openshift/rhc/pull/663.

Lowered the verbosity of ssh debug to level 2 instead of 3.

Comment 18 openshift-github-bot 2014-12-01 19:08:09 UTC
Commit pushed to master at https://github.com/openshift/rhc

https://github.com/openshift/rhc/commit/1569c48d6d70fa9c70f6eef5a8bab7e32c4ffe54
Bug 1149016 - lowering verbosity of ssh debug messages

Comment 21 openshift-github-bot 2014-12-02 14:35:40 UTC
Commit pushed to master at https://github.com/openshift/rhc

https://github.com/openshift/rhc/commit/f8e380a9b1351e7c742fbfd260e6d33a03753575
Bug 1149016 - lowering verbosity of ssh debug messages

Comment 22 DeShuai Ma 2014-12-03 08:23:49 UTC
Version-Release number of selected component (if applicable):
rhc version  : 1.33.3(build from source code on server devenv_5325)
online server: devenv_5335
os env : rhel6.5

steps to Reproduce:
1、create an app
# rhc app-create -a app1 php-5.3
2、use "-d" to ssh a app. can connect the app successfully and the terminal input normal
$ rhc -d ssh app1
[app1-eveusb.dev.rhcloud.com 547eeedce9c7a63350000002]\> ls
app-deployments  app-root  gear-registry  git  haproxy	unified-push

Actual results:
the terminal input normal

Expected results:
the terminal input normal

Comment 23 Josep 'Pep' Turro Mauri 2014-12-18 12:03:11 UTC
One remaining issue and an additional question.

The issue: on non-windows, the problem mentioned in comment #10 has only been fixed for the 'rhc ssh' command, but the snapshot command still doesn't work if --ssh is used to add ssh options:

  $ rhc -d snapshot save --ssh 'ssh -i ~/.ssh/id_test' test
  [...]
  DEBUG: "ssh -i ~/.ssh/id_test" 5492a859ecb0ca0b4f00000b.com 'snapshot' > test.tar.gz
  Pulling down a snapshot of application 'test' to test.tar.gz ... sh: ssh -i ~/.ssh/id_test: No such file or directory
  DEBUG: 
  Error in trying to save snapshot. You can try to save manually by running:
  "ssh -i ~/.ssh/id_test" 5492a859ecb0ca0b4f00000b.com 'snapshot' > test.tar.gz

Switching back to ASSIGNED for this.

The question: a customer just reported that rhc has troubles finding git/ssh; we're still checking details (versions, install locations etc) but meanwhile: it looks like the code (discover_windows_exectuables) searches in %ProgramFiles% and some default locations, but not %PATH% - is that right? Shouldn't we search PATH too?

Comment 24 Fabiano Franz 2015-01-05 16:25:24 UTC
> The question: a customer just reported that rhc has troubles finding
> git/ssh; we're still checking details (versions, install locations etc) but
> meanwhile: it looks like the code (discover_windows_exectuables) searches in
> %ProgramFiles% and some default locations, but not %PATH% - is that right?
> Shouldn't we search PATH too?

We do search for it on %PATH, that's provided by guessing locations without an explicit base path:

https://github.com/openshift/rhc/blob/master/lib/rhc/ssh_helpers.rb#L434
https://github.com/openshift/rhc/blob/master/lib/rhc/ssh_helpers.rb#L442

Comment 25 DeShuai Ma 2015-01-06 06:22:44 UTC
> We do search for it on %PATH, that's provided by guessing locations without
> an explicit base path:
> 
> https://github.com/openshift/rhc/blob/master/lib/rhc/ssh_helpers.rb#L434
> https://github.com/openshift/rhc/blob/master/lib/rhc/ssh_helpers.rb#L442

The execute command is error. When we combine the string to run, the command string should be " ssh -i ~/.ssh/id_test 5492a859ecb0ca0b4f00000b.com 'snapshot' > test.tar.gz " not " "ssh -i ~/.ssh/id_test" 5492a859ecb0ca0b4f00000b.com 'snapshot' > test.tar.gz "

we have Additional colon.

https://github.com/openshift/rhc/blob/master/lib/rhc/ssh_helpers.rb#L255
https://github.com/openshift/rhc/blob/master/lib/rhc/ssh_helpers.rb#L294

Comment 26 Jordan Liggitt 2015-01-06 13:44:52 UTC
I think this will be fixed by https://github.com/openshift/rhc/pull/668

Comment 27 openshift-github-bot 2015-01-07 15:08:16 UTC
Commit pushed to master at https://github.com/openshift/rhc

https://github.com/openshift/rhc/commit/285f6cc79e4750aa98b5033f450a0430c5c7b71c
Bug 1149016 - allow spaces in paths for --ssh flag but still allow arguments.

Executable path must be quoted within the string with escaped quotes if it contains spaces in the path

Comment 28 Jessica Forrester 2015-01-07 15:12:02 UTC
See the updated help text for 'rhc app ssh --help' that explains how to properly escape an ssh executable path with a space in it.  This should now work when the executable has a space in the path and arguments are passed.

Comment 29 DeShuai Ma 2015-01-08 05:23:35 UTC
Version-Release number of selected component (if applicable):
rhc version  : 1.34.1(build from source code on server devenv_5381)
online server: devenv_5381
os env : rhel6.5  win7

steps to Reproduce:
1、create an app
# rhc app-create -a app1 php-5.3
2、on rhel system, use "--ssh" to ssh, snapshot save and restore the app.
# rhc -d app-ssh -a app1 --ssh 'ssh -i ~/.ssh/id_rsa'
# rhc -d snapshot save --ssh 'ssh -i ~/.ssh/id_rsa' app1
# rhc -d snapshot restore --filepath=app1.tar.gz --ssh 'ssh -i ~/.ssh/id_rsa' app1

3. on win7 system
C:\Users\Win7x64\.ssh> rhc -d ssh app1 --ssh "ssh.exe -i id_rsa"
C:\Users\Win7x64\.ssh> rhc -d snapshot save --ssh 'ssh.exe -i id_rsa' app1
C:\Users\Win7x64\.ssh> rhc -d snapshot restore --filepath=app1.tar.gz --ssh "ssh.exe -i id_rsa" app1

Actual results:
the step 2 and 3 is no error.

Expected results:
the step 2 and 3 is no error.


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