ropensci / ssh

Native SSH client in R based on libssh
https://docs.ropensci.org/ssh
Other
127 stars 21 forks source link

Problem with Windows Cygwin OpenSSH server #11

Closed synikitin closed 6 years ago

synikitin commented 6 years ago

Hi,

I am trying to use this package on Mac High Sierra 10.13.2 with R 3.4.3 and libssh pulled with brew against a native Windows 10 client running a ssh server. Some commands, like, ping or whoami work fine, but many, like dir, do not. When it works, I get

ssh::ssh_exec_wait(sess, "whoami")
client2\administrator
[1] 0

but when it does not, I get

ssh::ssh_exec_wait(sess, "dir")
Error: libssh failure at 'ssh_channel_request_exec': Channel request exec failed

Any ideas?

jeroen commented 6 years ago

I don't think dir is a unix command? Try ls -ltr instead :)

synikitin commented 6 years ago

If I ssh from the Mac terminal to the Windows box, I get a Windows shell, so dir is what I have to use and there is no problem - I forgot to mention that in the original description. It is just when I try to do the same using the package, the session is buggy.

jeroen commented 6 years ago

Maybe the problem then is that the ssh package is giving you a bash shell instead? Do the bash commands work fine?

synikitin commented 6 years ago

I finally found a command that discriminated between windows and linux, ipconfig versus ifconfig - the former returns results and the later is not found. Still not sure what the issue is, but here is a detailed trace of a failure:

cat(rawToChar(ssh::ssh_exec_internal(sess, "dir")$stdout))

channel_open: Creating a channel 44 with 64000 window and 32768 max packet
packet_send2: packet: wrote [len=44,padding=19,comp=24,payload=24]
channel_open: Sent a SSH_MSG_CHANNEL_OPEN type session for channel 44
ssh_packet_socket_callback: packet: read type 2 [len=12,padding=6,comp=5,payload=5]
ssh_packet_process: Dispatching handler for packet type 2
ssh_packet_ignore_callback: Received SSH_MSG_IGNORE packet
ssh_socket_unbuffered_write: Enabling POLLOUT for socket
ssh_packet_socket_callback: packet: read type 91 [len=28,padding=10,comp=17,payload=17]
ssh_packet_process: Dispatching handler for packet type 91
ssh_packet_channel_open_conf: Received SSH2_MSG_CHANNEL_OPEN_CONFIRMATION
ssh_packet_channel_open_conf: Received a CHANNEL_OPEN_CONFIRMATION for channel 44:0
ssh_packet_channel_open_conf: Remote window : 262144, maxpacket : 33024
ssh_socket_unbuffered_write: Enabling POLLOUT for socket
packet_send2: packet: wrote [len=44,padding=17,comp=26,payload=26]
channel_request: Sent a SSH_MSG_CHANNEL_REQUEST exec
ssh_packet_socket_callback: packet: read type 98 [len=44,padding=18,comp=25,payload=25]
ssh_packet_process: Dispatching handler for packet type 98
channel_rcv_request: received exit-status -2147023888
ssh_packet_socket_callback: packet: read type 97 [len=12,padding=6,comp=5,payload=5]
ssh_packet_process: Dispatching handler for packet type 97
channel_rcv_close: Received close on channel (44:0)
channel_rcv_close: Remote host not polite enough to send an eof before close
ssh_packet_socket_callback: Processing 48 bytes left in socket buffer
ssh_packet_socket_callback: packet: read type 100 [len=12,padding=6,comp=5,payload=5]
ssh_packet_process: Dispatching handler for packet type 100
ssh_packet_channel_failure: Received SSH_CHANNEL_FAILURE on channel (44:0)
channel_request: Channel request exec failed
ssh_socket_unbuffered_write: Enabling POLLOUT for socket
packet_send2: packet: wrote [len=12,padding=6,comp=5,payload=5]
ssh_channel_send_eof: Sent a EOF on client channel (44:0)
packet_send2: packet: wrote [len=12,padding=6,comp=5,payload=5]
ssh_channel_close: Sent a close on client channel (44:0)
ssh_socket_unbuffered_write: Enabling POLLOUT for socket
Error: libssh failure at 'ssh_channel_request_exec': Channel request exec failed

It fails pretty fast, the first indication that I see is channel_rcv_request: received exit-status -2147023888.

synikitin commented 6 years ago

Turns out, currently, the built-in ssh server in Windows 10 is very limited, allowing only a few commands. I changed to CygWin OpenSSH server, and it now works fine.

Thanks for your attention.