Setting up SFTP on Windows 2008

Recently, I had a task assigned to me to get SFTP up and running on a Windows 2008 server. I did some Googling and found a few resources, but only by combining the various bits of information was I able to get it up and running. I thought I’d throw it all together into a blog post, in the hopes that it will help someone else out.

Requirements

You will need to download the latest Cygwin package from cygwin.com (there’s a link to setup.exe halfway down the first page). You’ll also need to have administrator access to the Windows 2008 server.

Getting Started

After you’ve downloaded Cygwin’s setup.exe, right-click it and Run As Administrator. Choose to Install from Internet, keep the defaults for Root Directory and Install For All Users and leave the Local Package Directory at the default path. If you’re behind a proxy, you’ll want to use Internet Explorer’s settings, or enter the proxy information. If not, direct connection will work great. Choose a mirror (I chose the one from kernel.org), and click OK for the warning about upgrading Cygwin (since this is theoretically your first time to install it). On the package selection page, type SSH into the Search box, then expand the Net selection. Click on openssh to select the binary package only. Select the required dependent packages on the next screen and wait for the installation to finish.

Configuration

After the installation is completed, find the Cygwin Bash Shell icon (should be on your Start Menu or Desktop), and right-click to Run As Administrator. You’ll see some initial configurations running, then will be presented with a prompt. At the prompt, enter ssh-host-config to get started. You’ll be presented the wizard below. Feel free to answer as I’ve listed, or change as needed.

  1. Should privilege separation be used? <yes>
  2. Should this script attempt to create a new local account ‘sshd’? <yes>
  3. Do you want to install sshd as a service? <yes>
  4. Enter the value of CYGWIN for the daemon <> (this is the service name)
  5. Do you want to use a different name (privileged acct cyg_server) <no>
  6. Create new privileged user account ‘cyg_server’? <yes>
  7. Please enter the password? [your choice]
  8. Reenter the password
  9. Setup is complete. Enter net start sshd at the prompt to start the service.

Users & Groups

By default, all local groups and local users will be added to C:\Cygwin\etc\group and C:\Cygwin\etc\passwd, respectively. You can add additional local groups (created after Cygwin install/sshd configuration by using the following command at the Cygwin Bash Shell prompt:

  • mkgroup -l -g “Group Name” >> /etc/group

You can also add domain-based groups with:

  • mkgroup -d -g “Group Name” >> /etc/group

Add additional local or domain-based users in much the same way:

  • mkpasswd -l -u “username” >> /etc/passwd
  • mkpasswd -d -u “username” >> /etc/passwd

Home Directories

By default, all users you add to the passwd file (or users present during initial configuration), will be mapped to /home/username (within Cygwin Bash Shell), or C:\Cygwin\home\username in Windows.

If you wish to change the home directory for a particular user, then use a text editor to edit the home directory path in /etc/passwd. If you wish to point the user’s home directory to another folder within Windows, then you must use Cygwin’s cygdrive to do so. As an example, the C:\ drive is known to Cygwin as /cygdrive/c. The D:\ drive is /cygdrive/d, and so on. If you want to set the home directory to point to D:\directory, then the appropriate home directory path is /cygdrive/d/directory. Save and close /etc/passwd when you are done.

Testing

If you’ve made any changes to /etc/group, or /etc/passwd, then you’ll want to restart the sshd service for the changes to take effect. If not, make sure you’ve started the sshd service before moving forward with verifying that everything works as expected.

Fire up your favorite SFTP capable client (I prefer FileZilla or WinSCP), and point it towards your new SFTP server. Be sure to use a user whose group exists in /etc/group, and is listed in /etc/passwd.

Comments

  1. Perform gentle sequences of actions involving changes of direction, stopping/beginning
    and leaping to simulate the action of a basketball sport.

  2. Would love to perpetually get updated great blog! http://www.3dprostatecure.com/page.php?cata_id=53&id=288

  3. Es folgten jährliche Kongresse in
    London darüber hinaus Mailand. Anlässlich der dritten Konferenz
    1938 in Mailand wurde vonseiten Sanvenero Rosselli
    Chip neue internationale Blatt Plastica
    Chirurgica hrsg.. Er veranstaltete kombinieren
    Lehrkurs zu Händen das Seminar vonseiten Plastischen Chirurgen
    in Italien. Eine zusätzliche Auflage konnte
    bezüglich des Beginns des 2. Weltkrieges nicht mehr
    erfolgen (Converse 1964,1977 mehr noch 1967). Converse
    schreibt abschließend:
    » Solcher internationale Konferenz der ‚European
    Society of Plastic Surgery‘ war dieser
    Glanzleistung der Entstehung jener Plastischen
    Chirurgie vor DEM 2. Weltkrieg … Er erbrachte
    1936 Meilensteine der Fortschritte
    zu Händen die Anerkennung der Vorhandensein dieses
    neuen Zweigs jener Chirurgie, alles andere als bloß in solcher
    Öffentlichkeit sondern außerdem für die akademische
    Welt (Converse 1977).
    4.2.4 Besondere Beiträge
    in jener Wissenschaftliche Literatur zwischen
    den Weltkriegen
    Entscheidende Beiträge z. Hd. den Fortschritt solcher
    Plastischen Chirurgie sind von den alsdann
    genannten Autoren in jener Phase zwischen den beiden
    Weltkriegen (1918–1939) geleistet worden.
    Verbrennungen
    Yngve Zottermann wird in puncto seines im Vorhinein
    1933 elektrophysiologisch erbrachten Nachweises
    jener unterschiedlichen Leitungsgeschwindigkeit
    involvierter schmerzleitender Belästigen von Seiten Voigt
    (1982) im Mitgliedsbeitrag zur Monographie Die Verbrennungskrankheit,
    Entstehung, Fortschritt und Therapie
    berücksichtigt. Die Befund solcher unterschiedlichen
    anatomisch im Übrigen physiologisch bedingten
    Schmerzleitungsgeschwindigkeiten führte zur
    einer wissenschaftlichen obendrein kühl erprobten
    Indikation welcher medikamentösen Schmerzbehandlung
    Brandverletzter.

  4. Hi there I am so glad I found your site, I really found you by mistake, while I was looking
    on Aol for something else, Anyhow I am here now and would
    just like to say thank you for a remarkable post and a
    all round entertaining blog (I also love the theme/design), I don’t have time to read through it all at the
    minute but I have bookmarked it and also included your RSS feeds, so when I have time
    I will be back to read more, Please do keep up the excellent work.

  5. Quality articles is the crucial to interest
    the users to pay a visit the web page, that’s what this site is providing.

  6. I’m still learning from you, but I’m improving myself.
    I certainly love reading all that is posted on your site.Keep the tips coming.
    I loved it!

  7. What i do not realize is in truth how you are now not actually much more well-liked than you
    may be right now. You are so intelligent. You know thus considerably in terms of this subject,
    produced me individually consider it from numerous varied angles.
    Its like women and men aren’t involved unless it’s one thing to accomplish with Woman gaga!
    Your individual stuffs nice. At all times maintain it up!

  8. This post offers clear idea in support of the new people of blogging, that genuinely
    how to do running a blog.

  9. I like this weblog very much so much excellent info.

  10. Hi I am so thrilled I found your blog, I really found you by
    accident, while I was looking on Yahoo for something else, Anyhow I am here now
    and would just like to say thanks for a remarkable
    post and a all round thrilling blog (I also love the theme/design),
    I don’t have time to look over it all at the moment but I have saved
    it and also added your RSS feeds, so when I have time I will be back to
    read a great deal more, Please do keep up the fantastic work.

  11. fantastic issues altogether, you just received a new
    reader. What would you suggest in regards to your publish that
    you simply made some days in the past? Any sure?

  12. There’s certainly a great deal to find out about this topic.

    I love all of the points you made.

  13. Hi colleagues, good post and nice urging commented at this place, I am truly enjoying by these.

  14. You should take part in a contest for one of the most useful blogs on the
    net. I most certainly will highly recommend this website!

  15. To compete with unlimited choices from opponents within the wi-fi business, Enhance Cellular introduced on January 15,
    2009, that it might launch a Monthly Unlimited Plan.

  16. Hi everyone, it’s my first go to see at this web page, and article is genuinely fruitful in support of me,
    keep up posting such articles.

  17. With havin so much content and articles do you ever run into any issues
    of plagorism or copyright violation? My site has a
    lot of unique content I’ve either written myself or outsourced but it
    looks like a lot of it is popping it up all over
    the internet without my permission. Do you know any methods to help stop content from being ripped off?
    I’d genuinely appreciate it.

  18. Thanks designed for sharing such a pleasant thinking, paragraph is good, thats why i have
    read it entirely

  19. Great blog you’ve got here.. It’s hard to find good quality writing like yours these days.
    I seriously appreciate individuals like you! Take care!!

  20. It’s not my first time to pay a quick visit this site, i am visiting this site
    dailly and take nice data from here everyday.

  21. This piece of writing will assist the internet viewers for creating new webpage or even a weblog from
    start to end.

  22. Attractive section of content. I just stumbled
    upon your blog and in accession capital to claim that I get actually enjoyed account
    your blog posts. Anyway I will be subscribing in your feeds and
    even I success you get entry to persistently quickly.

  23. Remember that the price is additionally suffering from the price
    in order to check first the free sizes given which has a specific value.
    Variety and use of files ought to be the first consideration. Nevertheless Avatar
    beat Titanic with 3D IMAGES effects a short while
    ago, Titanic continues to be viewed as an eternal classic
    in video industry.

  24. Hi there colleagues, its enormous paragraph regarding tutoringand entirely defined,
    keep it up all the time.

  25. What i don’t realize is in truth how you’re now not really a lot more neatly-preferred than you might be right now.
    You are very intelligent. You know thus considerably relating to this matter, produced me personally believe
    it from numerous various angles. Its like men and women aren’t fascinated except
    it is one thing to do with Woman gaga! Your own stuffs outstanding.
    All the time take care of it up!

  26. Wow, amazing blog format! How long have you been running a blog for?
    you made running a blog glance easy. The total glance of your web site is great,
    as neatly as the content!

  27. 「きょうは何となしに、自由にしとこうかな?」カナフレックス2chさんをお昼に誘い出すつもりで連絡を入れたら、第一声がこれでした。

    その事から、きょう、実にに久々にカナフレックス2chさんに逢いました。

  28. I have noticed you don’t monetize your blog, don’t waste your traffic, you can earn extra bucks every month because you’ve got high quality
    content. If you want to know how to make extra money, search for: best adsense alternative Wrastain’s
    tools

  29. Thank you for another informative site. Where else may I am getting that type of information written in such
    an ideal approach? I’ve a mission that I am simply now working on, and I’ve been at the glance out for such info.

  30. What’s up, I would like to subscribe for this web site to get latest updates, therefore where can i do it
    please help out.

  31. This page truly has all the information and facts I wanted about this subject and didn’t
    know who to ask.

  32. New Year Celebration kits and bulk halloween and fiesta.

  33. It’s an remarkable post for all the web visitors;
    they will obtain benefit from it I am sure.

  34. RScottyH43 says:

    One more thing. [still running as admin] Hmm, so I’ve tried cd’g into /etc/group and /etc/passwd, respectively and I am met with, “-bash: cd: /etc/group: No such file or directory”

    🙁 Will they only exist after creating a group and/or password?

    And one last thing. Just for sanity-sake, here’s a thought: I wish for a group of folks to be able to sftp into the box and use a particular folder/dir. I simply could create a group for them, yes, and then assign the group access to that particular folder, right? So, basically ‘bob’, ‘joe’, and ‘sally’ should be able to sftp and put stuff in folder ‘ftp_here’.

    Thanks in advance.

    • RScottyH43 says:

      Ok. I answered my own question! I now see these files after running mkgroup and mkpasswd. So, now I take it the info contained in these files is pulled from Active Directory?

  35. RScottyH43 says:

    Thanks much for this walk-through!

    Tried different solutions and finally came upon Cygwin, which worked! Although, just a tidbit of info, Cygwin-32 seems to setup as expected vs. Cygwin64, which gave me all sorts of trouble. Also, configuration now asks, “Should StrictModes by used?” Answer ‘yes’, then continue as noted above.

  36. Michael says:

    I am trying to isolate a local user so they can only access their home location with no access to other folders in the root. How can this be done as I am running into so issues trying to do this.

  37. craig88 says:

    Once you get sftp setup you may encounter these problems:
    1) admin user can login but regular users cannot. Is your server a domain controller? :
    http://serverfault.com/questions/159272/cant-login-to-cygwin-sshd-server-with-a-non-administrator-user-account

    2) allow sftp access but not shell access:
    edit /etc/sshd_config and add per user (or group) force command :
    Match User ftpuser
    ForceCommand /usr/sbin/sftp-server -l INFO

    3) restrict your sftp users to only their own directory
    the standard method is with chrootdirectory but that doesn’t seem to work on cygwin
    I don’t have that many users so I set windows security deny permissions for all directories but their own.

    after all that I was wishing i’d tried out this sftp server:
    http://www.coreftp.com/


  38. Kuldeep:

    Hi ,
    I have edited the password file to point to D:\some_directory.
    But still it is pointing to its old home directory.
    Note: I have tried restarting the service, after editing the password file.
    Please help.
    RegardsKuldeep.

  39. Hi ,

    I have edited the password file to point to D:\some_directory.

    But still it is not pointing to its old home directory.

    Note: I have tried restarting the service, after editing the password file.

    Please help.

    Regards
    Kuldeep.

  40. Hi,

    Thanks so much for this “how to”.
    It worked 100% for me.

    Sven

  41. Hello,

    Thank you for psoting this tutorial. well explained. I tried to install SFTP as per your tutorial and am struck after this:
    ————————-
    Find the Cygwin Bash Shell icon (should be on your Start Menu or Desktop), and right-click to Run As Administrator. You’ll see some initial configurations running, then will be presented with a prompt. At the prompt, enter ssh-host-config to get started.
    —————–

    I got the prompt and entered ssh-host-config and it gave me an error “bash: ssh-host-config: command not found”.

    Am unable to proceed from here. Please help.

    Regards

    SNair007iN

  42. Doesn’t Windows 2008 come with a secure ftp solution out of the usage of IIS? Of course, I know it is suppose to be ftps and not sftp but it would provide a similar solution without the need for cygwin. Don’t get me wrong… I love the usage of cygwin. I use them on my on windows systems to allow me to connect to windows boxes with ssh here at home.

  43. Setting up SFTP on Windows 2008 (vmDK) http://bit.ly/bvp5BP

    This comment was originally posted onTwitter

  44. Setting up SFTP on Windows 2008 (vmDK) http://bit.ly/8YVLlp

    This comment was originally posted onTwitter

  45. {Blog Post} Setting up SFTP on Windows 2008 http://bit.ly/dw7IZn

    This comment was originally posted onTwitter

Speak Your Mind

*