How to uninstall/reinstall cygwin to use the sshd?

60,488

Solution 1

I had to do three steps to make it reinstalled.

  • delete LOCAL_MACHINE\SYSTEM\ControlSet001\services\sshd
  • run 'sc delete sshd'
  • reboot

The problem is that I can't login the cygwin from the Mac, which is the exact reason I tried to reinstall the cygwin.

I made another thread about this problem. -> I can't login cygwin/ssh from Mac

Solution 2

If sshd has been previously installed on the system, the following cleanup procedure should be performed before invoking ssh-host-config:

# Remove sshd service
cygrunsrv --stop sshd
cygrunsrv --remove sshd

# Delete any sshd or related users (such as cyg_server) from /etc/passwd
#   (use your favorite editor)

# Delete any sshd or related users (such as cyg_server) from the system
net user sshd /delete
net user cyg_server /delete

Solution 3

Looking at this link

https://www.cygwin.com/ml/cygwin/2014-03/msg00315.html

somebody's suggestion from the above link, seems to be a great checklist, exhaustive, no shortcuts and quick, and IIRC it worked for me.

Remove all files related to ssh from /etc.
Remove /var/empty.
Remove the ssh logs from /var/log.
Remove the sshd and cyg_server accounts from your SAM. Drop both from /etc/passwd.
Remove the sshd service. Start over.

Note- Where it says "start over", that might be american talk for restart , in this case, windows. Where it says to remove a service, you may need or want to stop the service before removing it. It may be that you don't need a restart, though you may. (so you could just only restart if it still didn't work). And where it says "your SAM" that means where it stores windows users - they're shown in 'computer management' - cygwin ssh adds users there, I see cyg_server and sshd users there, you can delete them from gui or command line. And re stopping and deleting a service, there are many commands that can. cygrunsrv, sc, net, and of those, i've not seen an advantage with cygrunsrv. and this jay guy thinks sc is more reliable at stopping or deleting them, that may be so. Other answers have you covered re commands to stop and remove a service.

Share:
60,488

Related videos on Youtube

Obi Wan Kenobi
Author by

Obi Wan Kenobi

Updated on September 17, 2022

Comments

  • Obi Wan Kenobi
    Obi Wan Kenobi over 1 year

    I installed cygwin/sshd without good results. I removed the c:\cygwin directory to reinstall. I removed the sshd Administrator user by hand.

    I reinstalled the cygwin again, then run the 'ssh-host-config -y'. Strangely, it doesn't ask anything about making a new user. And the procedure is really short.

    $ ssh-host-config -y
    * Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
     Info: Creating default /etc/ssh_config file
     Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
     Info: Creating default /etc/sshd_config file
     Info: Privilege separation is set to yes by default since OpenSSH 3.3.
     Info: However, this requires a non-privileged account called 'sshd'.
     Info: For more info on privilege separation read /usr/share/doc/openssh
    ME.privsep.
    * Query: Should privilege separation be used? (yes/no) yes
    *** Info: Updating /etc/sshd_config file

    *** Info: Host configuration finished. Have fun!

    When I ran 'cygrunsrv -S sshd', I get an error. "Win 32 error 1069: The service did not start due to logon failure". It's reasonable message, as I deleted the sshd as a user, and the reinstall procedure did nothing for that again.

    I see I got something wrong with the uninstallation.

    Q: How can I uninstall the sshd related thing perfectly so that I can reinstall it again?

  • f.ardelian
    f.ardelian about 9 years
    Note that, as when sshd was installed, the cygwin shell must be run as Administrator.
  • John
    John over 8 years
    There was no file /etc/passwd for me. Other than that, this worked!
  • barlop
    barlop over 8 years
    You said "# Delete any sshd or related users (such as cyg_server) from /etc/passwd" OK. But then you said "# Delete any sshd or relaged users (such as cyg_server) from the system" That seems to be repeating yourself. And then you said the net user commands below that line. But those commands don't delete users from the system. They delete the services.
  • ndemou
    ndemou almost 7 years
    With system users he's referring to users of your windows PC. With /etc/passwd users he's referring to users defined within this file for the cygwin Unix-y environment (if any). "Those commands" do delete users: technet.microsoft.com/en-us/library/cc771865(v=ws.11).aspx
  • ndemou
    ndemou almost 7 years
    I found mine in ControlSet002 after a quick search for keys matching "sshd"