确保etc和var目录权限
Administrator@apple /etc
$ ls -ld /*
drwxrwxr-x+ 22 Administrators None 0 Jun 11 10:47 /etc
drwxrwxrwx+ 12 Administrators None 0 Nov 11 2008 /var
查看以前是否安装过ssd,使用下面的命令删除服务
Administrator@apple ~
$ cygrunsrv -L
sshd
Administrator@apple ~
$ cygrunsrv -R sshd
删除以前安装的sshd的配置文件
Administrator@apple ~
$ rm /etc/ssh* -f
删除以前安装的sshd的日志文件
Administrator@apple ~
$ rm /var/log/sshd.log
使用ssh-host-config设置sshd
Administrator@apple ~
$ ssh-host-config
*** 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_config file
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ
ME.privsep.
*** Query: Should privilege separation be used? (yes/no) yes
*** Warning: The file /etc/passwd is not readable by all.
*** Warning: Please run 'chmod +r /etc/passwd'.
*** ERROR: Problem with LocalSystem or Adminstrator IDs
说/etc/passwd权限有问题,使用下面的命令修改这个文件的权限
Administrator@apple ~
$ chmod +r /etc/passwd
如果/etc/group文件权限不对的话,需要修改/etc/group的权限
再一次删除配置和日志文件
Administrator@apple ~
$ rm /etc/ssh* -f
Administrator@apple ~
$ rm /var/log/sshd.log
rm: cannot remove `/var/log/sshd.log': No such file or directory
再一次使用ssh-host-config配置sshd
Administrator@apple ~
$ ssh-host-config
*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
*** Info: Creating default /etc/ssh_config file
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ
ME.privsep.
*** Query: Should privilege separation be used? (yes/no) yes
*** Info: Updating /etc/sshd_config file
*** Query: Overwrite existing /etc/inetd.d/sshd-inetd file? (yes/no) yes
*** Info: Creating default /etc/inetd.d/sshd-inetd file
*** Info: Updated /etc/inetd.d/sshd-inetd
*** Warning: The following functions require administrator privileges!
*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes
*** Info: Note that the CYGWIN variable must contain at least "ntsec"
*** Info: for sshd to be able to change user context without password.
*** Query: Enter the value of CYGWIN for the daemon: [ntsec]
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other 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 Windows 2003 Server or later. On 2003 and
*** Info: later systems, it's not possible to use the LocalSystem account
*** Info: for services that can change the user id without an explicit password
*** Info: (such as passwordless logins [e.g. public key authentication] via sshd
).
*** Info: If you want to enable that functionality, it's required to create a ne
w
*** Info: account with special privileges (unless a similar account already exis
ts).
*** Info: This account is then used to run these special servers.
*** Info: Note that creating a new user requires that the current account have
*** Info: Administrator privileges itself.
*** Info: The following privileged accounts were found: 'cyg_server' .
*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will not be able to log on interactively, but will only
*** Info: be used by registered services.
*** Query: Do you want to use different name? (yes/no) no
*** Query: Please enter the password for user 'cyg_server':
*** Query: Reenter:
*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account. To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'. Otherwise, it will start automatically
*** Info: after the next reboot.
*** Info: Host configuration finished. Have fun!
使用下面的命令启动sshd服务
Administrator@apple ~
$ cygrunsrv -S sshd
注意:
sshd在cyg_server帐户下运行,
好运!