Unable to connect to SSH after generated public key and private key

cygwin;opensshssh

Can some one help ? I have installed openssh (version OpenSSH_6.8p1) in windows 7 and I have generated the public and private keys, however I'm not able to connect to that SSH. I'm getting an error "Connection closed by 127.0.0.1" if I use the command "ssh localhost" .

However I'm able to connect by skipping the public key authentication via "ssh localhost -o PubkeyAuthentication=no"

Output of the command "ssh -v localhost"

OpenSSH_6.8p1, OpenSSL 1.0.2a 19 Mar 2015
debug1: Reading
configuration data /etc/ssh_config
debug1: Connecting to localhost
[127.0.0.1] port 22.
debug1: Connection established.
debug1:
identity file /home/Vinoth/.ssh/id_rsa type 1
debug1:
key_load_public: No such file or directory
debug1: identity file
/home/Vinoth/.ssh/id_rsa-cert type -1
debug1: key_load_public: No
such file or directory
debug1: identity file
/home/Vinoth/.ssh/id_dsa type -1
debug1: key_load_public: No such
file or directory
debug1: identity file
/home/Vinoth/.ssh/id_dsa-cert type -1
debug1: key_load_public: No
such file or directory
debug1: identity file
/home/Vinoth/.ssh/id_ecdsa type -1
debug1: key_load_public: No
such file or directory
debug1: identity file
/home/Vinoth/.ssh/id_ecdsa-cert type -1
debug1: key_load_public:
No such file or directory
debug1: identity file
/home/Vinoth/.ssh/id_ed25519 type -1
debug1: key_load_public: No
such file or directory
debug1: identity file
/home/Vinoth/.ssh/id_ed25519-cert type -1
debug1: Enabling
compatibility mode for protocol 2.0
debug1: Local version string
SSH-2.0-OpenSSH_6.8
debug1: Remote protocol version 2.0, remote
software version OpenSSH_6.8
debug1: match: OpenSSH_6.8 pat
OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client
aes128-ctr umac-64-etm@openssh.com none
debug1: kex:
client->server aes128-ctr umac-64-etm@openssh.com none
debug1:
expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key:
ecdsa-sha2-nistp256 SHA256:4Lnpmdki8UuIiQtJyZoc2vxu8x9l
PVSN4vykW+axilc
debug1: Host 'localhost' is known and matches the
ECDSA host key.
debug1: Found key in
/home/Vinoth/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS
received
debug1: Roaming not allowed by server
debug1:
SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT
received
debug1: Authentications that can continue:
publickey,password,keyboard-interacti ve
debug1: Next
authentication method: publickey
debug1: Offering RSA public key:
/home/Vinoth/.ssh/id_rsa
Connection closed by 127.0.0.1

List of files under .ssh folder

$ ls -lrt
total 7
-rwxrwx— 1 Vinoth None 519 Jun 11 18:36 known_hosts
-rw-rw—- 1 Vinoth None 1679 Jun 12 00:48 id_rsa
-rw-rw—- 1 Vinoth None 398 Jun 12 00:48 id_rsa.pub
-rw-rw—- 1 Vinoth None 398 Jun 12 23:47 authorized_keys

List of Files under /var/log

$ ls -lrt
total 54101
-rw-r–r– 1 Vinoth Administrators 35167 Jun 11 15:10 setup.log
-rw-r–r– 1 Vinoth Administrators 25541 Jun 11 15:10 setup.log.full
-rw—-r– 1 SYSTEM SYSTEM 469 Jun 11 15:43 sshd.log
-rw-r–r– 1 sshd Administrators 55330520 Jun 13 00:57 lastlog

sshd.log is not updating . lastlog file is not readable

cat sshd.log

Vinoth@Vinoth-HP /var/log
$ cat /var/log/sshd.log
/var/empty must be owned by root and not group or world-writable.

Best Answer

The most likely explanation is that you have not set adequately restrictive file permissions on the keys in question. You may wish to set

  chmod 600 id_rsa
  chmod 600 id_rsa.pub
  cat id_rsa.pub >> authorized_keys
  chmod 600 authorized_keys

which is strict enough.

Related Question