Cygwin, sshd and Windows 7

It seems like installing OpenSSH (sshd) on Windows 7 is a bit of a hassle. When I first upgraded to 7 from WinXP, I simply copied across my Cygwin directory and it just worked. However, it was later I realised that it would not let me log in if using public key authentication. So I decided to install it from scratch. I’ve always used Nicholas Fong’s article when installing openssh as the procedure¬† is quick and painless. But this is when I realised Windows 7 requires the sshd user to have extra privileges to get it work properly. The steps in the aforementioned site gets around this creating a new user called cyg_server. Personally, I don’t like having extra users, so I tried to find out how to give myself the same permissions without the need to create a new user.

With these instructions, you can fix the public key authentication problem and run sshd as Administrator or an existing user (even your own user account):

  1. You should have already installed cygwin and openssh by now. If not, what are you waiting for? Christmas? :P
  2. Undo any previous attempts to install the sshd service:
    $ net stop sshd
    $ cygrunsrv -R sshd
    $ net user sshd /DELETE  # See note below
    $ rm -R /etc/ssh*
    $ mkpasswd -cl > /etc/passwd
    $ mkgroup --local > /etc/group

    # Run `net user` to find out if there’s any other such users that could have run sshd – example “sshd” or “cyg_server”. Delete these as well. Don’t delete any default Windows ones!

  3. Decide on a user account that you want to run the sshd process. This can Administrator as well except its disabled on Windows 7 by default (it can be enabled by running lusrmgr.msc). For these instructions, lets say you want a user called MyUser to run sshd.
  4. Check existing permissions for MyUser (in case you need to roll back, keep a note of its output):
    $ editrights -l -u MyUser
  5. Add additional privileges to allow sshd to run as a service:
    $ editrights.exe -a SeAssignPrimaryTokenPrivilege -u MyUser
    $ editrights.exe -a SeCreateTokenPrivilege -u MyUser
    $ editrights.exe -a SeTcbPrivilege -u MyUser
    $ editrights.exe -a SeServiceLogonRight -u MyUser
  6. Run ssh-host-config (don’t force the -y option):
    $ ssh-host-config
  7. Answer yes to all questions making sure when it asks “Do you want to use a different name?”, say “yes” (this question is different with the -y option)
  8. Enter your desired username and password when you are prompted. You should *not* see any warnings. If you do, you might not have set all privileges correctly
  9. If all goes well, start sshd:
    $ net start sshd

Disclaimer: Do this at your risk. Since your user gets these additional permissions, it may cause a few security issues (I can’t see any major issues though). You can find more information on user privileges at Microsoft Technet. Tested only on Cygwin 1.7.1 and Windows 7 Professional (64 bit).

PS: For those that are curious, the cygwin scripts that automatically made the new users were /usr/share/csih/ and /usr/bin/ssh-host-config. Looking through those scripts made it obvious what the problem was (Function: csih_account_has_necessary_privileges()).

To be or not to be…

Not to be. Deleted all crappy old posts. Time to put some decent posts here ;-)

How to Sleep 5-6 Hours In a Day, and Survive the Next Day

I have always, always had sleeping problems. Although I’ve never suffered from insomnia (as I’ve always felt the need to sleep 7-8 hrs/day), I have always been most active nocturnally. This has had its pros and cons as I went from high school to university and to full-time employment. After starting work at the awesome, for the first time in years, I could fall asleep within 10 minutes of getting in bed. For a time, it was good.

As I started studying part time again this year (while working full time), I needed to spend more time awake, just to get everything done. In early May, I started an experiment. An experiment to sleep 5-6 hours a day.

Week 1: The First Step is the Hardest
For no particular reason, I decided to start this on a Monday. So after a fun weekend, my first day back was after 5.5 hours of sleep. One of the worst feelings ever. I knew, whatever happens, I should stay away from caffeine. Easier said than done. I had 3 cans of V that week. Not as bad I would have thought. I required around 20 minutes of power naps everyday, just enough to recharge my batteries after work. Waking up on time in the mornings was extremely difficult. Some ways I managed to overcome this is by drawing the curtains straight after waking up (sunlight really helps), jumping into the shower straight away, and (believe it or not) checking my emails first thing in the morning!

Week 2: Persistence + RSI
In some ways, this week was harder. I stopped taking caffeine based products, and stuck to taking low GI products like Nutella and lots of nuts (almomds to be specific) as in-between snacks. Sleeping 2-3 hours less is quite tough on the body. Which means, my body needs to eat more. Since I didn’t have time for another meal, protein shakes worked well. It doesn’t have to be commercially bought, you can make one yourself! Another problem that could develop is RSI. Last year, I was actively playing tennis, and I never really got much RSI. This time however, I suffered extremely serious case of RSI, so bad that I had to take Voltaren. Back to exercise it was, and surely enough, RSI symptoms soon disappeared.

Week 3: The Hard Part’s Over
If you managed 2 weeks without cheating (ie, consistent sleeping patterns, low/no caffeine, exercise), this week will be quite interesting. Your productivity will be awesome. The only problem that I seem to remember from week 3 was that I kept getting easily distracted. This is where you should remember; it’s not the hours you put in, it’s what you put in the hours! Listen to music before starting to work, or while working. It helps a lot to get you into the mood.

I reckon it might a little easier to start this plan in summer, as the morning sun really helps you get out of bed quicker. I did it in the middle of winter, and it wasn’t too bad :) I have 2-3 hours extra in a day now, that’s 14-21 hours in a week!

So, to sum it up:


  • Caffeine
  • Doing Catch-Up Sleeps in the Weekends
  • Power naps greater than 20 minutes


  • Water
  • Low GI Products
  • Power naps – I didn’t need this after about 3-4 weeks
  • Exercise – a good 2-hour session of tennis weekly has been great. Going for a run works well also.
  • Sunlight – free source of vitamin D

My girl friend was quite concerned about my sleeping habits. To a certain extent, so was I. From google, I can see this guy doing something similar to me. Needless to say, he’s a programmer also ;) There were quite bunch of articles that also mentioned the bad effects of sleeping less than 8 hours a day. So if you’re willing to try this, proceed at your own risk.

Update: 18th August, 2007
I have now completely stopped doing power naps. I don’t even need it anymore, which is great! Also, I sleep 6-6.5 hours in weekends. I can do 7 also but I get headaches if I sleep longer. Btw, headaches have been normal for me ever since I can remember. Everytime I excessively slept, I had headaches. Apparently, 8 hours is excessive sleep now :)

IMDb’s First 100

A few days ago, as I was browsing IMDb (as I always do after watching a movie), and I realised Marlon Brando had a really small primary key (8 to be precise). So out of curiosity, I checked who had the id of 1, and then 2 and then I wanted to know all the others as well.

Well, I finally had 10 minutes to spare so thought to write a script to see how these entries are defined. Not surprisingly, the movie titles are ordered in chronological order. I’ve left that list at the end of this blog entry in case you’re curious.

The actors listing however, is quite interesting and I can’t see much pattern in it at all. My guess would have been its the original id’s from when IMDb first started, but that was in the early 90’s. Surely, actors like Jennifer Aniston wouldn’t be there. Also, why would Gillian Anderson be there, and not David Duchovny! Ah well, it’s one of those mysteries which only imdb creators might know.


  1. Fred Astaire
  2. Lauren Bacall
  3. Brigitte Bardot
  4. John Belushi
  5. Ingmar Bergman
  6. Ingrid Bergman (I)
  7. Humphrey Bogart
  8. Marlon Brando
  9. Richard Burton (I)
  10. James Cagney
  11. Gary Cooper (I)
  12. Bette Davis
  13. Doris Day (I)
  14. Olivia de Havilland
  15. James Dean (I)
  16. Georges Delerue
  17. Marlene Dietrich
  18. Kirk Douglas (I)
  19. Federico Fellini
  20. Henry Fonda
  21. Joan Fontaine
  22. Clark Gable
  23. Judy Garland (I)
  24. John Gielgud
  25. Jerry Goldsmith
  26. Cary Grant
  27. Alec Guinness
  28. Rita Hayworth
  29. Margaux Hemingway
  30. Audrey Hepburn
  31. Katharine Hepburn
  32. Charlton Heston
  33. Alfred Hitchcock (I)
  34. William Holden (I)
  35. James Horner
  36. Buster Keaton
  37. Gene Kelly (I)
  38. Grace Kelly (I)
  39. Deborah Kerr
  40. Stanley Kubrick
  41. Akira Kurosawa
  42. Alan Ladd (I)
  43. Veronica Lake (I)
  44. Burt Lancaster
  45. Bruce Lee (I)
  46. Vivien Leigh
  47. Sophia Loren
  48. Peter Lorre (I)
  49. Henry Mancini
  50. Groucho Marx
  51. James Mason (I)
  52. Marcello Mastroianni
  53. Robert Mitchum
  54. Marilyn Monroe
  55. Alfred Newman
  56. Paul Newman (I)
  57. David Niven (I)
  58. Maureen O’Hara
  59. Laurence Olivier
  60. Gregory Peck
  61. Tyrone Power (I)
  62. Elvis Presley
  63. Anthony Quinn (I)
  64. Edward G. Robinson
  65. Nino Rota
  66. Jane Russell (I)
  67. Miklós Rózsa
  68. Randolph Scott (I)
  69. Frank Sinatra
  70. Max Steiner (I)
  71. James Stewart (I)
  72. Elizabeth Taylor (I)
  73. Shirley Temple
  74. Gene Tierney
  75. Spencer Tracy
  76. François Truffaut
  77. Franz Waxman
  78. John Wayne (I)
  79. Raquel Welch
  80. Orson Welles
  81. Natalie Wood (I)
  82. Victor Young (I)
  83. Alan Miller (III)
  84. Li Gong (I)
  85. Henner Hofmann
  86. Louis de Funès
  87. Yelena Koreneva
  88. Aleksei Korenev
  89. Richard Paul (I)
  90. Armin Mueller-Stahl
  91. Gérard Pirès
  92. John Cleese
  93. Brad Pitt
  94. J Reifel
  95. Woody Allen
  96. Gillian Anderson (I)
  97. Pamela Anderson (I)
  98. Jennifer Aniston
  99. Patricia Arquette
  100. Rowan Atkinson


(possibly among the first 100 movies ever made)

  1. Carmencita (1894)
  2. Clown et ses chiens, Le (1892)
  3. Pauvre Pierrot (1892)
  4. Un bon bock (1892)
  5. Blacksmith Scene (1893)
  6. Chinese Opium Den (1894)
  7. Corbett and Courtney Before the Kinetograph (1894)
  8. Edison Kinetoscopic Record of a Sneeze (1894)
  9. Miss Jerry (1894)
  10. Sortie des usines Lumière, La (1895)
  11. Akrobatisches Potpourri (1895)
  12. Arrivée d’un train à La Ciotat, L’ (1895)
  13. Neuville-sur-Saône: Débarquement du congrès des photographes à Lyon (1895)
  14. Arroseur arrosé, L’ (1895)
  15. Autour d’une cabine (1895)
  16. Barque sortant du port (1895)
  17. Bauerntanz zweier Kinder (1895)
  18. Boxende Känguruh, Das (1895)
  19. The Clown Barber (1895)
  20. The Derby (1895)
  21. Neuville-sur-Saône: Débarquement du congrès des photographes à Lyon (1895)
  22. Forgerons, Les (1895)
  23. Mer, La (1895)
  24. Opening of the Kiel Canal (1895)
  25. The Oxford and Cambridge University Boat Race (1895)
  26. Partie de cartes (1895)
  27. Place des Cordeliers à Lyon (1895)
  28. Pêche aux poissons rouges, La (1895)
  29. Repas de bébé (1895)
  30. Rough Sea at Dover (1895)
  31. Saut à la couverture, Le (1895)
  32. Serpentinen Tanz (1895)
  33. Voltige, La (1895)
  34. Arrivée d’un train gare de Vincennes (1896)
  35. Arroseur, L’ (1896)
  36. Awakening of Rip (1896)
  37. Baignade en mer (1896)
  38. The Ball Game (1898)
  39. Barnet Horse Fair (1896)
  40. Barque sortant du port de Trouville (1896)
  41. Bataille de boules de neige (1896)
  42. Bateau-mouche sur la Seine (1896)
  43. Batteuse à vapeur (1896)
  44. Bivouac, Le (1896)
  45. Blanchisseuses, Les (1896)
  46. Bois de Boulogne (1896)
  47. Boulevard des Italiens (1896)
  48. The Boxing Kangaroo (1896)
  49. Boxing Match; or, Glove Contest (1896)
  50. Bébé et fillettes (1896)
  51. Campement de bohémiens (1896)
  52. Carga de rurales (1896)
  53. A Chegada do Comboio Inaugural à Estação Central do Porto (1897)
  54. Chevaux de bois, Les (1896)
  55. Chiffonnier, Le (1896)
  56. Uma Corrida de Touros no Campo Pequeno (1896)
  57. Cortège de tzar allant à Versailles (1896)
  58. Cortège de tzar au Bois de Boulogne (1896)
  59. Couronnement de la rosière (1896)
  60. Dancing Darkies (1896)
  61. Dancing Girls (1896)
  62. Danse serpentine (1896)
  63. Dessinateur express (1896)
  64. Dessinateur: Chamberlain (1896)
  65. Dessinateur: Reine Victoria (1896)
  66. Dessinateur: Von Bismark (1896)
  67. Dix chapeaux en 60 secondes (1896)
  68. Déchargement de bateaux (1896)
  69. Défense d’afficher (1896)
  70. Démolition d’un mur (1896)
  71. Départ des automobiles (1896)
  72. Départ des officiers (1896)
  73. Effets de mer sur les rochers (1896)
  74. Enfants jouant sur la plage (1896)
  75. Escamotage d’une dame au théâtre Robert Houdin (1896)
  76. Exit of Rip and the Dwarf (1896)
  77. Fakir, mystère indien, Le (1896)
  78. Feira de Gado na Corujeira (1896)
  79. Gare Saint-Lazare, La (1896)
  80. Grandes manoeuvres (1896)
  81. Haleurs de bateaux, Les (1896)
  82. A Hard Wash (1896)
  83. Indiscrets, Les (1896)
  84. Ivrognes, Les (1896)
  85. Jardinier brûlant des herbes (1896)
  86. Jetée et plage de Trouville (1er partie) (1896)
  87. Jetée et plage de Trouville (2e partie) (1896)
  88. Jour de marché à Trouville (1896)
  89. Départ de Jérusalem en chemin de fer (1897)
  90. Libération des territoriaux (1896)
  91. Manoir du diable, Le (1896)
  92. Marée montante sur Brise-Larmes (1896)
  93. Melbourne (1896)
  94. Miss de Vere (1896)
  95. Papier protée, Le (1896)
  96. Place Saint-Augustin (1896)
  97. Place de l’Opéra, 1er aspect (1896)
  98. Place de l’Opéra, 2e aspect (1896)
  99. Place de la Bastille (1896)
  100. Place de la Concorde (1896)