Skip to content

[Question] about sftp.exe #228

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

Closed
fjaenal opened this issue May 24, 2016 · 5 comments
Closed

[Question] about sftp.exe #228

fjaenal opened this issue May 24, 2016 · 5 comments

Comments

@fjaenal
Copy link

fjaenal commented May 24, 2016

Due to this issue I am having in #218 I am putting in place a workaround. The workaround is to use the sftp.exe client to grab the file I need. However, this needs to be done without a user / password interaction.

I have the following batch file (sftp_transfer_test.bat):
REM Connect to SFTP server using a password
open sftp://Administrator:[email protected]/ -hostkey=""
REM Download file
get /C:/Windows/Temp/UnisphereMapper_IRENSANTOTL1C_10.73.28.168/storage_resources.out c:\views\test
REM Exit
exit

Then I run: "sftp -vvv -P 22201 -bsftp_transfer_test.bat [email protected]"

But I get the following error: "Host key verification failed." (Bellow the log file from the sftp. exe client.
debug2: host key algorithms: ssh-rsa,ecdsa-sha2-nistp256
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],umac-6
[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],umac-6
[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: compression: none
debug1: kex: client->server cipher: [email protected] MAC: compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: w32_write fd:3
debug2: send - io:006B4970
debug2: send - WSASend() returned 0, APC scheduled io:006B4970
debug2: WSASendCB - io:006B4970, pending_state:1, error:0, sent:48 of remaining:48
debug3: w32_select fd:3
debug3: Total in fds:1
debug2: on_select - io:006B4970 type:1 rd:1
debug3: WSARecv - pio: 006B4970
debug2: WSARecv - reported IO pending
debug3: wait() on 0 events and 0 childres
debug3: wait() on 0 events and 0 childres
debug2: WSARecvCompletionCB - io:006B4970, pending_state:1, flags:0, error:0, received:280
debug3: select - returning 1
debug3: w32_read fd:3
debug3: recv - io:006B4970
debug2: recv - returning 280 bytes from prior completed IO, remaining:0, io:006B4970
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xId4pUm9kTkCer8CuH5VwaSqRFpZLBjNI2p7XLGkb24
debug3: put_host_port: [10.73.28.168]:22201
debug3: put_host_port: [10.73.28.168]:22201
debug3: hostkeys_foreach: reading file "C:\Users\jaenf.ssh\known_hosts"
debug3: hostkeys_foreach: reading file "C:\Users\jaenf.ssh\known_hosts"
debug1: checking without port identifier
debug3: hostkeys_foreach: reading file "C:\Users\jaenf.ssh\known_hosts"
Host key verification failed.
debug2: ReadCB pio:00487578, pending_state:1, error:109, received:0
debug2: read - (2) no more data, io:00487578
Connection closed

I think I am doing something wrong with the key configuration, both in the sshd server and the client keys. Does anyone know how to configure this properly? (With the response and the help I will put some examples on the wiki)

--> Related with this, when trying to connect with non interactive (just with keys):
When trying to connect with JSCH I get this error:
INFO: Tue May 24 08:52:11 BST 2016:: SSH_MSG_KEX_ECDH_INIT sent
INFO: Tue May 24 08:52:11 BST 2016:: expecting SSH_MSG_KEX_ECDH_REPLY
INFO: Tue May 24 08:52:11 BST 2016:: ssh_rsa_verify: signature true
INFO: Tue May 24 08:52:11 BST 2016:: Disconnecting from 10.73.28.168 port 22201
com.jcraft.jsch.JSchException: UnknownHostKey: 10.73.28.168. RSA key fingerprint is 00:25:de:b0:7a:1c:3f:c3:b0:62:5d:b6:0f:17:d6:70

The connection is done with this piece of code:
JSch jsch = new JSch(); jsch.addIdentity("C:\\Users\\jaenf\\.ssh\\id_rsa"); jsch.addIdentity("C:\\Users\\jaenf\\.ssh\\id_dsa"); jsch.addIdentity("C:\\Users\\jaenf\\.ssh\\id_ecdsa"); Hashtable<String, String> config = new Hashtable<String, String>(); config.put("cipher.s2c", "aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,blowfish-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-ctr,arcfour,arcfour128,arcfour256"); config.put("cipher.c2s", "aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,blowfish-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-ctr,arcfour,arcfour128,arcfour256"); config.put("StrictModes", "yes"); session = jsch.getSession(user, host, port); // Adding the private keys in the communication. session.setIdentityRepository(jsch.getIdentityRepository()); session.setConfig(config); session.setTimeout(60000); // SESSION_TIMEOUT System.out.println("Establishing Connection..."); session.connect();

Francisco

@manojampalam
Copy link
Contributor

I'll take a look at #218 this weekend.

@manojampalam
Copy link
Contributor

Can you try out latest release?

@fjaenal
Copy link
Author

fjaenal commented Jun 1, 2016

@manojampalam ok, I'll test it as soon as possible.
Thanks for the help !!!!

@fjaenal
Copy link
Author

fjaenal commented Jun 7, 2016

@manojampalam Tested with both (A JSCH java client and WinSCP). Now it works. Can be closed !!!!!

As a curiosity, Where was the error? Reading the remote file or in the transport layer?

Again thanks for taking the time to look to this !!!!!

@manojampalam
Copy link
Contributor

It was a file offset bug in the POSIX wrapper that I had written.

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

2 participants