Showing posts with label cygrunsrv. Show all posts
Showing posts with label cygrunsrv. Show all posts

Thursday, October 14, 2010

Cygwin: Update your packages / Install a new one in less than 5 minutes

[what is cygwin? like unix for windows. a better shell and command line.]
Actually, it's the same way you _install cygwin_ ..
Just faster because you don't have to download as much.

If you're installing cygwin for the first time, installing a single missing package,
or updating your install to the latest version, it's the same.
  1. Run cygwin's setup.exe -- the same one you used to install cygwin.
    This took me 2 minutes, because I couldn't remember where I put it.
    Better: just go to cygwin.com and click the Install or update Cygwin now! link and you'll have the latest installer.
  2. click, click, click, just click through, all your previous settings were saved.
    List of mirrors is downloaded
    ..hang?
    Pick a new mirror if you want. I used to think http: servers provided better downloads, but now I think they just hang more often. Use http: only if ftp: doesn't work for you (e.g. problems with ftp because you're behind a firewall).
  3. The list of packages is downloaded. This should be pretty quick; if you don't see any activity within 15 seconds or so, cancel and go back to 1.
  4. Select / search for the package(s) you want. Just type in the search area (e.g., cygrun) to find the package and select for install.
    (? if you don't know the package name.. where is a search for files ?)
    old ones are updated automatically ?
  5. Click next to install. All the package(s) are downloaded and installed.
    If it hangs, cancel and go back to 1. Maybe try a new mirror?
  6. "Can't install , file is in use" -- this can happen if
    1. you are running the .exe; for example, bash.exe and you have a bash.exe window open
    2. you are updating a .dll which is in use by your exe or service
    3. service is running, such as sshd. Do this:
    • open a cmd window
    • find the service(s) with the following command:
      net start | findstr /i cyg
      the service(s) names are printed
    • stop the service with
      net stop "CYGWIN sshd"
      replace with the name you have. (? other services besides CYGWIN ?)
    • click Retry on the dialog warning box
    • It should continue now. When you get to the end, remember to restart with
      net start "CYGWIN sshd"
      This is a generally useful way to stop/start services easily from the command line or from a script. If you prefer the slow way of clicking, you can run services.msc
  7. Finished!
    after updating my 1.5.x to 1.7.x, I get this for the cygrund package:
    Postinstall script errors
    Package: No package
    passwd-grp.sh exit code 1
    I got something like this when I first updated, but I haven't noticed any problem.
Actually, it could take more than 5 minutes, if there are slow downloads.
Once you get the hand of it though, it will probably only take two minutes to grab a missing package.

Because updating/adding a package is so easy, the first time you should click through and accept the defaults, then later adding missing features. I used to spend a lot of time going through all the packages, trying to decide if someday it might be useful. This just takes up more space, and more time later when upgrading.

Enhanced by Zemanta

Saturday, April 24, 2010

Setup sshd on cygwin in 4 minutes

4 steps, less than 4 minutes to do,
assuming: you have cygwin installed already, plus the requisite packages.
It took me less than twenty minutes (well, I had to perform some due diligence, even though I had done it before on another system. And the windows firewall issue).
All commands should be run in a bash shell unless directed otherwise.
  1. Check that you have cygrunsrv. The brute force method:
    $ cygrunsrv.exe -S sshd
    cygrunsrv: Error starting a service: OpenService: Win32 error 1060:
    The specified service does not exist as an installed service.
    If you get 'command not found', then you'll need to install the package.
  2. run ssh-host-config
    seemed to take a minute or so before I got any output, but maybe that's because my virtual machine didn't have much entropy for key generation.
    type 'yes' a couple times at the prompts, unless you don't want to.
  3. now install as a service:
    cygrunsrv.exe -S sshd
    when asked for value of CYGWIN, you can give:
    binmode tty ntsec

  4. start the service.. run services.msc (from a cmd window) or use 'net start'

All set?
Test from bash with 'ssh -v username@localhost'.
Now, test externally with 'ssh -v username@cygwinSshHost' .. if you don't see any output, windows firewall or other form of bandaid is keeping you out.

After you're logged in, do 'ssh-add -L >> ~/.ssh/authorized_keys2' so you don't need to type passwords to log in anymore (maybe on the second login, agent forwarding doesn't happen on a new host ?).

More steps, with more detail: How to configure cygwin for sshd .