Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh connection on a Windows client #167

Closed
zack-vii opened this issue Oct 19, 2015 · 6 comments
Closed

ssh connection on a Windows client #167

zack-vii opened this issue Oct 19, 2015 · 6 comments
Assignees

Comments

@zack-vii
Copy link
Contributor

As Windows does not ship with a native ssh client, Windows ssh connections are no standard. MDSplus cannot connect from Windows or even crashes when trying to connect (e.g. by setting the environment variable '_path' to "ssh://::"). Is there already a workaround?
My suggestion adding a mdsip-client-ssh.bat in the system folder that uses a putty representation plink.exe ('http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter7.html'). plink is very light weight <400KB and could be added to the MDSplus bundle.
But it seems to need a bit more changes in the C code in order to work, i.e. it is not just the call of "mdsip-client-ssh "

@tfredian tfredian self-assigned this Nov 20, 2015
@tfredian tfredian added the bug An unexpected problem or unintended behavior label Nov 20, 2015
@tfredian
Copy link
Contributor

I will look into this. This used to work in the past with a couple different ssh packages for windows but this was prior to switching the windows builds to use mingw64 so perhaps there is either some incompatibility or the compiles with mingw64 exposed some bugs. I would prefer not to include plink in the MDSPlus distributions. To use plink with the existing ssh plugin you would need to make an ssh.bat file and put it in your PATH which would in turn run plink. It would be possible to make a simple plink plugin for mdsip which would only require the plink.exe to be in your PATH. There are also rumors about Microsoft finally providing traditional ssh client and server implementations too.

In any event I will see if I can track down the problem with the tunneling plugin on windows. It is currently segfaulting very early in the connect code which constructs a shell command, opens pipes for stdin and stdout and creates a subprocess to run the command. stdin and stdout are then just used to communicate through the ssh connection. Used to work but does not now.

@zack-vii
Copy link
Contributor Author

related #231

@tfredian
Copy link
Contributor

Timo Is this still a problem or was it fixed with: #231 ?

@zack-vii
Copy link
Contributor Author

Hm I cannot get it to work.. when executing from Linux the ssh login and remote call of mdsip-server-ssh does not return. However, the windows variant does after you entered you password. It does not return anymore if you replace %2 with ". /etc/profile;%2".
however when executed via mdsconnect ()eg in MATLAB of tditest) the password prompt does not show and the process hangs.
The plink support does not seem to work either.

it returns Error in connect
mdsopen: Could not open connection to MDS server
0

probably due to a incorrect translation of the ssh datastream done by plink.

plink -agent -batch -L 8000:%server%:8000 %user%@%server% -N
does open a tunnel which can then be used by mdsconnect to localhost
maybe that is a good work around
the code could open this tunnel internally and then redirect the data streams

@MDSplusBuilder
Copy link
Contributor

Weird. This worked without a hitch on my windows system with plink. I'll
try it again to make sure.

On 12/15/2015 11:06 AM, zack-vii wrote:

Hm I cannot get it to work.. when executing from Linux the ssh login
and remote call of mdsip-server-ssh does not return. However, the
windows variant does after you entered you password. It does not
return anymore if you replace %2 with ". /etc/profile;%2".
however when executed via mdsconnect ()eg in MATLAB of tditest) the
password prompt does not show and the process hangs.
The plink support does not seem to work either.

|it returns Error in connect mdsopen: Could not open connection to MDS
server 0 |

probably due to a incorrect translation of the ssh datastream done by
plink.

plink -agent -batch -L 8000:%server%:8000 %user%@%server% -N
does open a tunnel which can then be used by mdsconnect to localhost
maybe that is a good work around
the code could open this tunnel internally and then redirect the data
streams


Reply to this email directly or view it on GitHub
#167 (comment).

@tfredian
Copy link
Contributor

I just verified this works with plink on a clean install of putty with mdsplus-alpha-7.0.196 and mdsplus-alpha-7.0.197. The steps I used to test this is:

  1. Download and install putty-0.66-installer.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
  2. Run PuttyGen (Putty) and import an open-ssh2 private key which can be used to connect to the remote mdsplus system via ssh and export it in ppk format.
  3. Run the Pagent utility (Putty) and add a new key selecting the ppk file.
  4. From cmd.exe prompt do: plink username@mdsplus-system-host to ensure you can connect without password. Save the host's credentials into putty's known host cache.
  5. Try 4 again to make sure it connects without any additional prompting.
  6. Install MDSplus (I just downloaded and installed mdsplus-alpha-7.0.197).
  7. run tditest and enter the following:
    mdsconnect('ssh://username@mdsplus-system-host')
    mdsvalue('getenv("some-known-env-on-remote-host")')

The above worked fine on my system (Windows 10 clean install). It had also worked on Windows 7 prior to the Window 10 install with mdsplus-alpha-7.0.196.

Note that the username@ is needed in the connection string otherwise plink will prompt for the username which breaks the mdsip tunneling.

@tfredian tfredian removed the bug An unexpected problem or unintended behavior label Dec 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants