0

I am setting up a SSH password less connection setup for two server for the first time. I have imported a public key earlier by vi to authorized_keys, but since this was failing so i have asked remote Server team ( Windows using PSCP) to generate one more pri/pub key pair & imported the latest key also by appending the new key in the authorized_keys file. However I have not removed the earlier key from the authorized_keys and the SSH is still failing with same error. Could you please tell me if this is the reason for this failure. Below is the set of logs generated from the PSCP logging from remote server trying to connect
Event Log: Writing new session log (SSH packets mode) to file: D:\ssh\ssh.txt
Event Log: Server version: SSH-2.0-OpenSSH_5.3
Event Log: We believe remote version has SSH-2 channel request bug
Event Log: Using SSH protocol version 2
Outgoing packet #0x0, type 20 / 0x14 (SSH2_MSG_KEXINIT)
Incoming packet #0x0, type 20 / 0x14 (SSH2_MSG_KEXINIT)
Event Log: Doing Diffie-Hellman group exchange
Outgoing packet #0x1, type 34 / 0x22 (SSH2_MSG_KEX_DH_GEX_REQUEST)

Incoming packet #0x1, type 31 / 0x1f (SSH2_MSG_KEX_DH_GEX_GROUP)
Event Log: Doing Diffie-Hellman key exchange with hash SHA-256
Outgoing packet #0x2, type 32 / 0x20 (SSH2_MSG_KEX_DH_GEX_INIT)
Incoming packet #0x2, type 33 / 0x21 (SSH2_MSG_KEX_DH_GEX_REPLY)
Event Log: Host key fingerprint is:
Outgoing packet #0x3, type 21 / 0x15 (SSH2_MSG_NEWKEYS)
Event Log: Initialised AES-128 SDCTR client->server encryption
Event Log: Initialised HMAC-SHA-256 client->server MAC algorithm
Incoming packet #0x3, type 21 / 0x15 (SSH2_MSG_NEWKEYS)
Event Log: Initialised AES-128 SDCTR server->client encryption
Event Log: Initialised HMAC-SHA-256 server->client MAC algorithm
Outgoing packet #0x4, type 5 / 0x05 (SSH2_MSG_SERVICE_REQUEST)
Incoming packet #0x4, type 6 / 0x06 (SSH2_MSG_SERVICE_ACCEPT)
Event Log: Reading private key file "key.ppk"
Outgoing packet #0x5, type 50 / 0x32 (SSH2_MSG_USERAUTH_REQUEST)
Incoming packet #0x5, type 53 / 0x35 (SSH2_MSG_USERAUTH_BANNER)
Incoming packet #0x6, type 51 / 0x33 (SSH2_MSG_USERAUTH_FAILURE)
Outgoing packet #0x6, type 50 / 0x32 (SSH2_MSG_USERAUTH_REQUEST)
Event Log: Offered public key
Incoming packet #0x7, type 60 / 0x3c (SSH2_MSG_USERAUTH_PK_OK)
Event Log: Offer of public key accepted
Outgoing packet #0x7, type 50 / 0x32 (SSH2_MSG_USERAUTH_REQUEST)
Event Log: Sent public key signature
Event Log: Server unexpectedly closed network connection

Below the the logs from the windows server trying to connect to Linux generated via -v option of pscp
C:\Users\User>pscp -i "private.ppk" -P 22 -l User -v -sftp "file.txt" server.domain.com:/outboundpath/
Looking up host "server.domain.com"
Connecting to 199.199.199.127 port 22
We claim version: SSH-2.0-PuTTY_Release_0.67
Server version: SSH-2.0-OpenSSH_5.3
We believe remote version has SSH-2 channel request bug
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
Host key fingerprint is:
ssh-rsa 2048
Initialised AES-128 SDCTR client->server encryption
Initialised HMAC-SHA-256 client->server MAC algorithm
Initialised AES-128 SDCTR server->client encryption
Initialised HMAC-SHA-256 server->client MAC algorithm
Reading private key file "private.ppk"
Using username "connect". LEGAL NOTICE

      You may commit a criminal offence if you act outside your
               authority in relation to this computer.



Offered public key
Offer of public key accepted
Authenticating with public key "rsa-key-20170424"
Sent public key signature
Server unexpectedly closed network connection
Fatal: Server unexpectedly closed network connection

  • Usually errors like this are related to public key rejections or permissions errors. Double-check that the server is using the right permissions on .ssh and .authorized_keys and double-check that the key in the authorized key file doesn't have extraneous spaces or carriage returns. – Patrick Apr 26 '17 at 15:42
  • Thanks Patrick.... Could you please tell me if i already have a public key for same server in authorized keys file ( which i think was incorrect ) , will the adding the another public key for same server ( Newly generated ) by appending the new key after the old key will result into a issue – Abhinav May 9 '17 at 13:09
  • No. The authorized_keys file can contain multiple keys. Make sure when you're pasting in that there are no line breaks in the key, otherwise it will be considered invalid. This applies mainly to Windows editing programs, just double-check that you paste it in as one line. You can also use ssh-copy-id to automate the copying process over to the server. You will have to use password auth temporarily to get this to work. – Patrick May 9 '17 at 15:31
  • Thanks for info.... Could you please tell me how can i mark this as a answer. – Abhinav May 10 '17 at 6:55
  • I will post it as an answer so you can mark it. – Patrick May 10 '17 at 14:12
0

Usually errors like this are related to public key rejections or permissions errors. Double-check that the server is using the right permissions on .ssh and .authorized_keys and double-check that the key in the authorized key file doesn't have extraneous spaces or carriage returns.

The authorized_keys file can contain multiple keys. Make sure when you're pasting in that there are no line breaks in the key, otherwise it will be considered invalid. This applies mainly to Windows editing programs, just double-check that you paste it in as one line. You can also use ssh-copy-id to automate the copying process over to the server. You will have to use password auth temporarily to get this to work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.