正在使用的文件在windows下无法使用ftp工具下载，就考虑在windows下建立open ssh server,然后使用ssh client来下载的方式解决。
Configuration ------------- The most important step in getting the server to properly run is to correctly set up the passwd file. The passwd file is equivalent to the /etc/passwd file in UNIX-based systems. You will need to set up the passwd file before any logins can take place.
Passwd creation is fairly easy. The majority of user additions take place through the mkpasswd program. You must also create a group file with mkgroup. Mkgroup is included in the bin directory along with a slightly modified version of mkpasswd. Mkpasswd has been changed to automatically use /bin/switch as the default shell.
The steps to creating proper group and passwd files is outlined below. To add local groups to the group file, you use the -l switch, for domain groups, use the -d switch: mkgroup -l >> ..\etc\group (local groups) mkgroup -d >> ..\etc\group (domain groups)
If you use both commands, the group file will contain duplicates. You will need to remove these by hand in a text editor.
You will now need to create a passwd file. Any users in the passwd file will be able to log on with SSH. For this reason, it is recommended that you add users individually with the -u switch. To add ALL users on a system or domain, do not use the -u switch. As with mkgroup, local users are indicated with the -l switch and domain users are indicated by the -d switch. To add domain users from a domain that is not the primary domain of the machine, add the domain name after the user name: mkpasswd -l [-u <username>] >> ..\etc\passwd (add username to passwd - local user) mkpasswd -d [-u <username>] >> ..\etc\passwd (add username to passwd - domain user)
The passwd and group files are plain text and can be edited in Vim, Notepad or any text editor. Vim is recommended because it respects the default format of the files.
The last two entries for each user are safe to edit by hand, and can be customized to suit your needs. The second to last entry (/home/username) can be replaced with any other directory to act as that user's home directory (what directory they will be in after they log in). If you will be placing the user somewhere outside the default directory for their Windows profile, you will need to use the cygdrive notation explained below or edit the directory /home maps to. The last entry in passwd is the program that runs when you connect with SSH. The default shell is /bin/switch, which is the best choice for about 99.9% of the accounts you will be adding. Switch.exe allows the use of scp and sftp while still providing the standard command prompt with SSH by switching between sh.exe (scp/sftp) and cmd.exe. If you do not want sftp/scp access for a particular account you can set the shell to /bin/quietcmd.bat, which only runs cmd.exe.
Note that changes made to group are not automatically used by the ssh service. You will need to restart the OpenSSHd service before those changes can be used. Changes to passwd should be automatically used, but restarting the service will help if the changes are not applied automatically.
The /home Directory ------------------- In the passwd file, you will notice that the user's home directory is set as /home/username, with username being the name of the account. In the default install, the /home directory is set to the default profile directory for all users. This is usually C:\Documents and Settings on Windows 2000 and XP, and C:\WINNT\Profiles on Windows NT 4.0. The location of /home can be edited to fit your special requirements by editing a registry key.
To change the Windows directory /home corresponds to, you will need to edit a registry entry under HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/home. The value of the key named "native" is the directory that /home is. If you want all your users to enter in a directory on your machine called F:\Users, change "native" to read F:\Users. By default, each user will then be placed in the directory F:\Users\username, where username is the name of the user account. To place the user directly under f:\Users, change the home directory in passwd to /home.
Run the setup program and accept the defaults (all categories). This will install the OpenSSH server and client in an appropiate place.
Configuration ------------- 1. Open a command prompt and change to the installation directory (Program Files\OpenSSH is the default).
2. CD into the bin directory.
3. Use mkgroup to create a group permissions file. For local groups, use the "-l" switch. For domain groups, use the "-d" switch. For both domain and local, it is best to run the command twice (remember to use >>, not >). If you use both, make sure to edit the file to remove any duplicate entires.
mkgroup -l >> ..\etc\group (local groups) mkgroup -d >> ..\etc\group (domain groups)
4. Use mkpasswd to add authorized users into the passwd file. For local users, use the "-l" switch. For domain users, use the "-d" switch. For both domain and local, it is best to run the command twice (remember to use >>, not >). If you use both, make sure to edit the file to remove any duplicate entires.
mkpasswd -l [-u <username>] >> ..\etc\passwd (local users) mkpasswd -d [-u <username>] >> ..\etc\passwd (domain users)
NOTE: To add users from a domain that is not the primary domain of the machine, add the domain name after the user name. NOTE: Ommitting the username switch adds ALL users from the machine or domain, including service accounts and the Guest account.
5. Start the OpenSSH server.
net start opensshd
6. Test the server. Using a seperate machine as the client is best. If you connect but the connection immediately gets dropped, reboot the machine with the server and try connecting again.
Usage and Important Notes ------------------------- Remember that the CYGWIN OpenSSH utilities are not graphical and are command-line based. Look at PuTTY, SSH Secure Shell, etc for graphical configuration. For more advanced ways to use the programs, look at the manual pages in the documentation directory.
SSH (client program): ssh <user@servername>
SCP (file copy): scp <localfilename> <user@servername>:<destinationdirectory> or scp <user@servername>:<remotefilename> <localfilename> or scp <user@servername>:<remotefilename> <user@otherservername>:<destinationdirectory>
SFTP (ftp): sftp <user@servername>
NOTE: While regular SSH provides a familiar Windows commandline, SCP and SFTP as well as the passwd file use Unix-style paths. This is due partly to the Unix history of SSH, and to the Cygwin source of the tools.
Paths in SCP and SFTP as well as the home directory listing in passwd use Unix notation. To access directories outside of the OpenSSH directory structure, use the Cygdrive notation described in readme.txt. Further explanation is in readme.txt.