Connection closed by ::1 error in cygwin

16,968

Solution 1

My problem is solved. I just removed cygwin and re-installed it and somehow its working properly now.

Solution 2

I experienced this same issue. The problem for me at least, was the creation of the cyg_server user using the ssh-host-config. It was created without a home directory and with it's shell set to /bin/false. So, I altered the /etc/passwd file for the cyg_server user to reflect /home/cyg_server (changed from /var/empty) and /bin/false to /bin/bash and created the home directory for the user. Tried to reconnect using the cyg_server user and voila.

in short:

mkdir /home/cyg_server
vim /etc/passwd
cyg_server:...(bunch of stuff)...:/var/empty:/bin/false

to

cyg_server:...(bunch of stuff)...:/home/cyg_server:/bin/bash

Presumably cygwin has a usermod command or synonym that would do this a little safer. But I was impatient and this is what I did. If anyone follows this please note to be extremely careful when editing the /etc/passwd file.

Solution 3

Just in case other find the same problem. Since you selected the cyg_server as user name while configuring ssh try to connect as using "ssh cyg_server@localhost" command rather than the default "ssh localhost". The password can be same as what you provided while configuring

Solution 4

Putting this here in case someone runs into this later. I had the same problem and reinstalling cygwin solved it... until I rebooted. Then I got the same error again. I now resolved the problem for the second time: instead of using the account name "cyg_server" that cygwin suggests to me when running ssh-host-config, I entered the name of my normal admin account on windows. Seems to be working so far.

Share:
16,968
Shekhar
Author by

Shekhar

Currently working as a Techno architect for AstraZeneca. Have vast experience of Big Data application design, planning, development, deployment and other phases of application development. Have hands on experience in Amazon Web Services, Hadoop, Hive, Pig, HBase, Kafka, IoT, Java, Storm technologies.

Updated on June 04, 2022

Comments

  • Shekhar
    Shekhar almost 2 years

    I am trying to do ssh connection using cygwin. I have followed instructions given here. When I fire ssh localhost command I get Connection closed by ::1 error. As I am newbie to unix and cygwin, I am not able to figure out what has gone wrong. Please can anyone tell me why this error comes and how to resolve it?

    My cygwin shell looks as follows :

    $ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/Shekhar/.ssh/id_rsa):
    /home/Shekhar/.ssh/id_rsa already exists.
    Overwrite (y/n)? y
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/Shekhar/.ssh/id_rsa.
    Your public key has been saved in /home/Shekhar/.ssh/id_rsa.pub.
    The key fingerprint is:
    85:69:77:cc:fd:21:8a:ce:fe:46:41:ee:c8:e7:3d:7b Shekhar@Shekhar-PC
    The key's randomart image is:
    +--[ RSA 2048]----+
    |                 |
    |         o + .   |
    |        + = +... |
    |       . o.+. ...|
    |        S.o..   .|
    |        oo +     |
    |         o+ .    |
    |        .  o o E |
    |         .o. .+  |
    +-----------------+
    
    Shekhar@Shekhar-PC ~
    $ cd ~/.ssh/
    
    Shekhar@Shekhar-PC ~/.ssh
    $ ls -l
    total 10
    -rw-r--r-- 1 Shekhar None 1200 Jun 16 19:49 authorized_keys
    -rw------- 1 Shekhar None 1675 Jun 20 08:55 id_rsa
    -rw-r--r-- 1 Shekhar None  400 Jun 20 08:55 id_rsa.pub
    -rw-r--r-- 1 Shekhar None  171 Jun  6 23:28 known_hosts
    
    Shekhar@Shekhar-PC ~/.ssh
    $ cat id_rsa.pub >> authorized_keys
    
    Shekhar@Shekhar-PC ~/.ssh
    $ ssh localhost
    Connection closed by ::1
    
  • Pragmateek
    Pragmateek about 11 years
    Thanks a lot Sabosan for your answer: this solved my issue too +1 :)
  • Shekhar
    Shekhar almost 11 years
    can anyone explain reason for downvoting?
  • sushain97
    sushain97 over 10 years
    +1. Worked perfectly.
  • kakyo
    kakyo about 10 years
    I had to do these to fix Op's problem: chown <USERNAME> /var/log/sshd.log chown -R <USERNAME> /var/empty chown <USERNAME> /etc/ssh* chmod 755 /var/empty chmod 644 /var/log/sshd.log
  • James Selvakumar
    James Selvakumar almost 10 years
    I found the ownership of /var/empty correctly set to cyg_server:Root. So I didn't change the home directory of cyg_server. Instead I changed only the shell from /bin/false to /bin/bash and it worked perfectly. Another thing is that users should ensure that cygwin batch file is run with administrator privileges. Many thanks.
  • Shailendra
    Shailendra about 9 years
    I followed the suggestions and logged in using cyg_server and it worked like a charm ! Thanks !
  • Admin
    Admin over 8 years
    Because reinstalling OS on a minor issue is not a good advice
  • Shekhar
    Shekhar over 8 years
    Please read answer carefully before down voting. I reinstalled Cygwin, I didn't reinstalled OS.
  • Admin
    Admin over 8 years
    Yeah but you reinstalled cygwin. It is not a very good advice. I used OS just to give an example.