步骤一:
在vm win2k3
里安装cygwin
环境,虚拟机上不了外网,所以就在我的工作机上下载了一个cygwin
的安装包,完整的,640M
。
把这个包拷贝到虚拟机里面,完全安装,
安装的中间出现很奇怪的进度显示,如下所示。
安装了很长时间,至少有1h
,完成之后,双击cygwin
无法使用。在另一台虚拟机里也试着安装了一下,也是没有成功。很郁闷。
步骤二:
把我自己的工作机(winxp)上的cygwin的安装包压缩后传到vm上,1,8G
,上传之后解压到C盘。到cygwin目录下,双击Cygwin.bat,成功打开bash环境。在桌面上做了一个快捷键。如下
步骤三:
配置ssh
服务器。
1) 添加环境变量CYGWIN和path。
2) 授权。
chmod +r /etc/group
chmod +r /etc/passwd
chmod +rwx /var
3) 安装sshd服务
$ ssh-host-config # 引导SSH服务配置
*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Creating default /etc/ssh_configfile
*** Info: Creating default /etc/sshd_configfile
*** Info: Privilege separation is set toyes by default since OpenSSH 3.3.
*** Info: However, this requires anon-privileged account called 'sshd'.
*** Info: For more info on privilegeseparation read /usr/share/doc/openssh/READ
ME.privsep.
*** Query: Should privilege separation beused? (yes/no) yes #
输入
yes
*** Info: Updating /etc/sshd_config file
*** Warning: The following functionsrequire administrator privileges!
*** Query: Do you want to install sshd as aservice?
*** Query: (Say "no" if it isalready installed as a service) (yes/no) yes #
输入
yes
*** Info: Note that the CYGWIN variablemust contain at least "ntsec"
*** Info: for sshd to be able to changeuser context without password.
*** Query: Enter the value of CYGWIN forthe daemon: [ntsec] ntsec #
输入
ntsec
*** Info: On Windows Server 2003, WindowsVista, and above, the
*** Info: SYSTEM account cannot setuid toother users -- a capability
*** Info: sshd requires. You need to have or to create a privileged
*** Info: account. This script will help you do so.
*** Info: You appear to be running Windows2003 Server or later. On 2003 and
*** Info: later systems, it's not possibleto use the LocalSystem account
*** Info: for services that can change theuser id without an explicit password
*** Info: (such as passwordless logins[e.g. public key authentication] via sshd).
*** Info: If you want to enable thatfunctionality, it's required to create a new
*** Info: account with special privileges(unless a similar account already exists).
*** Info: This account is then used to runthese special servers.
*** Info: Note that creating a new userrequires that the current account have
*** Info: Administrator privileges itself.
*** Info: No privileged account could befound.
*** Info: This script plans to use'cyg_server'.
*** Info: 'cyg_server' will only be used byregistered services.
*** Query: Do you want to use a differentname? (yes/no) no #
输入
no
,不指定启动用户
*** Query: Create new privileged useraccount 'cyg_server'? (yes/no) no #
输入
no
,不指定启动用户
*** ERROR: There was a serious problemcreating a privileged user.
*** Query: Do you want to proceed anyway?(yes/no) yes #
输入
yes
*** Warning: Expected privileged user'cyg_server' does not exist.
*** Warning: Defaulting to 'SYSTEM'
*** Info: The sshd service has beeninstalled under the LocalSystem
*** Info: account (also known as SYSTEM).To start the service now, call
*** Info: `net start sshd' or `cygrunsrv -Ssshd'. Otherwise, it
*** Info: will start automatically afterthe next reboot.
*** Info: Host configuration finished. Havefun!
4)
Net start sshd # 启动 SSH服务
5) 注意: 使用 windows 用户本地认证
mkpasswd-l > /etc/passwd 使用windows 用户的密码
mkgroup -l > /etc/group 使用windows 用户组
6) 启动完成之后ssh Administrator@localhost提示输入密码,输入正确的密码,可以成功登陆,则ssh配置成功。
问题:
Q:
安装的时候出现如下错误Error installing a service: OpenService: Win32 error 1073:
重新安装sshd
服务,要先到注册表中删除对应的注册信息。
HKEY_LOCAL_MACHINE\HKEY_LOCAL_MACHINE\SYSTEM\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sshd
Q: cygrunsrv -Ssshd
不能启动,报告
cygrunsrv: Error starting a service:QueryServiceStatus: Win32 error 1062:
The service has not been started.
A:
很可能是/var/log
的权限设置不正确。首先执行mkpasswd
和 mkgroup
重新生成权限信息,再删除sshd
服务,重新配置:
$ mkpasswd -l > /etc/passwd
$ mkgroup -l > /etc/group
$ cygrunsrv -R sshd
$ ssh-host-config -y
$ cygrunsrv -S sshd