0

I'm trying to connect a Linux (CentOS 6.5 x64) server and another server, a Windows Server 2008 R2 running Cygwin, and transfer files daily via SSHD from Linux to Windows, and I will use public keys for authentication. The Windows server is recognized and is a know host in Linux SSH, but when I try to copy the Linux public key to Windows server via scp command, it returns:

Connection closed by <host IP> lost connection`

In sshd_config file, there's a line allowing connections as root (commented as default), I uncommented and remained the same. I tried turn off Windows Firewall, but not worked. Is something wrong with my Cygwin/SSHD settings, or Linux SSHD?

ssh -v output:

ssh -v <Windows server user>@<Host IP>
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.1.23 [192.168.1.23] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/identity-cert type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.1.23' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
Connection closed by <Host IP>
9
  • Is the Windows firewall opened? Try a simple ssh connection witht the -v option instead if using scp and see if you get any useful errors.
    – Zoredache
    Oct 10, 2014 at 22:17
  • I opened port 22 and turned down the firewall, there's ssh output (resumed, the entire output is too long): debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/identity debug1: Offering public key: /root/.ssh/id_rsa Connection closed by <host IP> Once the port is opened, will be the same output. Looks like something only in the server.
    – jiyamesu
    Oct 10, 2014 at 22:20
  • entire output is too long - Edit your question and add it to the question.
    – Zoredache
    Oct 10, 2014 at 22:25
  • @Zoredache There is
    – jiyamesu
    Oct 10, 2014 at 22:31
  • You seem to be connecting to the server just fine. You probably need to check the logs on the SSH server next.
    – Zoredache
    Oct 10, 2014 at 23:36

1 Answer 1

0

If you are trying to copy keys to the Windows box then I assume you are just getting set up. Make sure you are allowed to connect with a password and if you are connecting as root allow that as well. Make sure public key authentication is enabled as well.

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication yes
PermitRootLogin yes

As important as these are it's just as important to be sure the opposite settings don't exist (i.e. RSAAuthentication no somewhere). Before you try scp, go ahead and just ssh into it with the user and password you are trying to copy with. Examples assume username is joe and server is devsrv:

ssh joe@devsrv

Once you see this works then try your copy with:

scp mykey.pub joe@devsrv:/tmp/foo

Once you have your keys copied over disable password authentication with PasswordAuthentication no

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .