1. 程式人生 > >Cygwin-安裝和配置ssh服務

Cygwin-安裝和配置ssh服務

Cygwin介紹:

Cygwin是一個在windows平臺上執行的類UNIX模擬環境,它對於學習UNIX/Linux操作環境,或者從UNIX到Windows的應用程式移植,或者進行某些特殊的開發工作,尤其是使用GNU工具集在Windows上進行嵌入式系統開發,非常有用。

因為要學習hadoop分散式檔案系統,想在window下模擬linux環境進行部署。所以想到用cygwin工具。

先將幾個我在安裝過程中遇到的問題:

1.安裝時最好明確自己要安裝那些服務,根據自己的實際需要而定,我一次安裝就因為漏選了openssh,後來重灌了,

2.重灌可以不用先解除安裝,直接點選setup.exe,進行安裝,

3.那個選擇下載站點就選預設的就好了http://mirrons.163.com。

4.安裝ssh服務時配置無密碼是總是出錯

錯誤如下:刪掉.ssh資料夾,用密碼登陸也是不成功。試了好幾次,也重灌了cygwin64位還是無效,最後安裝cygwin32位的才可以。

[email protected] ~
$  cd ~/.ssh

[email protected]~/.ssh
$ ssh localhost
[email protected]'s password:
      2 [main] sshd 3804 D:\SofeWare\cygwin\usr\sbin\sshd.exe: *** fatal error - NtCreateEvent(lock): 0xC0000058
Connection to localhost closed.

注意配置 ssh的時候,yes/no的選擇要小心點,不小心就會出錯。
[email protected] ~
$ ssh-host-config

*** Info: Generating missing SSH host keys
ssh-keygen: generating new host keys: RSA1 RSA DSA ECDSA ED25519
*** Info: Creating default /etc/ssh_config file
*** Info: Creating default /etc/sshd_config file

*** Info: StrictModes is set to 'yes' by default.
*** Info: This is the recommended setting, but it requires that the POSIX
*** Info: permissions of the user's home directory, the user's .ssh
*** Info: directory, and the user's ssh key files are tight so that
*** Info: only the user has write permissions.
*** Info: On the other hand, StrictModes don't work well with default
*** Info: Windows permissions of a home directory mounted with the
*** Info: 'noacl' option, and they don't work at all if the home
*** Info: directory is on a FAT or FAT32 partition.
*** Query: Should StrictModes be used? (yes/no) no

*** Info: Privilege separation is set to 'sandbox' by default since
*** Info: OpenSSH 6.1.  This is unsupported by Cygwin and has to be set
*** Info: to 'yes' or 'no'.
*** Info: However, using privilege separation requires a non-privileged account
*** Info: called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep.
*** Query: Should privilege separation be used? (yes/no) no
*** Info: Updating /etc/sshd_config file

*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes
*** 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: It's not possible to use the LocalSystem account for services
*** Info: that can change the user id without an explicit password
*** Info: (such as passwordless logins [e.g. public key authentication]
*** Info: via sshd) when having to create the user token from scratch.
*** Info: For more information on this requirement, see
*** Info: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless such an account
*** Info: already exists). This account is then used to run these special
*** Info: servers.

*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.

*** Info: No privileged account could be found.

*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'LYX\cyg_server' (Cygwin name: 'cyg_server')? (yes/no) no
*** ERROR: There was a serious problem creating a privileged user.
*** Query: Do you want to proceed anyway? (yes/no) no

[email protected]
~ $ ssh-host-config *** Info: Generating missing SSH host keys *** 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: StrictModes is set to 'yes' by default. *** Info: This is the recommended setting, but it requires that the POSIX *** Info: permissions of the user's home directory, the user's .ssh *** Info: directory, and the user's ssh key files are tight so that *** Info: only the user has write permissions. *** Info: On the other hand, StrictModes don't work well with default *** Info: Windows permissions of a home directory mounted with the *** Info: 'noacl' option, and they don't work at all if the home *** Info: directory is on a FAT or FAT32 partition. *** Query: Should StrictModes be used? (yes/no) yes *** Info: Privilege separation is set to 'sandbox' by default since *** Info: OpenSSH 6.1. This is unsupported by Cygwin and has to be set *** Info: to 'yes' or 'no'. *** Info: However, using privilege separation requires a non-privileged account *** Info: called 'sshd'. *** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep. *** Query: Should privilege separation be used? (yes/no) no *** Info: Updating /etc/sshd_config file *** Query: Do you want to install sshd as a service? *** Query: (Say "no" if it is already installed as a service) (yes/no) yes *** Query: Enter the value of CYGWIN for the daemon: [] netsec *** 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: It's not possible to use the LocalSystem account for services *** Info: that can change the user id without an explicit password *** Info: (such as passwordless logins [e.g. public key authentication] *** Info: via sshd) when having to create the user token from scratch. *** Info: For more information on this requirement, see *** Info: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1 *** Info: If you want to enable that functionality, it's required to create *** Info: a new account with special privileges (unless such an account *** Info: already exists). This account is then used to run these special *** Info: servers. *** Info: Note that creating a new user requires that the current account *** Info: have Administrator privileges itself. *** Info: No privileged account could be found. *** Info: This script plans to use 'cyg_server'. *** Info: 'cyg_server' will only be used by registered services. *** Query: Do you want to use a different name? (yes/no) yes *** Query: Enter the new user name: l *** Query: Reenter: l *** Query: Create new privileged user account 'LYX\lyx' (Cygwin name: 'l')? (yes/no) yes *** Info: Please enter a password for new user lyx. Please be sure *** Info: that this password matches the password rules given on your system. *** Info: Entering no password will exit the configuration. *** Query: Please enter the password: *** Query: Reenter: *** Warning: Creating the user 'l' failed! Reason: ▒û▒▒▒▒▒▒▒▒▒▒▒▒ƿ▒▒Բ▒ͬ▒▒ ▒▒▒▒▒ NET HELPMSG 2253 ▒Ի▒ø▒▒▒İ▒▒▒▒▒ *** ERROR: There was a serious problem creating a privileged user. *** Query: Do you want to proceed anyway? (yes/no) yes *** Warning: Expected privileged user 'lyx' does not exist. *** Warning: Defaulting to 'SYSTEM' *** Info: The sshd service has been installed under the LocalSystem *** Info: account (also known as SYSTEM). To start the service now, call *** Info: `net start sshd' or `cygrunsrv -S sshd'. Otherwise, it *** Info: will start automatically after the next reboot. *** Warning: Host configuration exited with 1 errors or warnings! *** Warning: Make sure that all problems reported are fixed, *** Warning: then re-run ssh-host-config. [email protected] ~ $ ssh localhost The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is SHA256:5/i9vvXBBfiqhzLrekd9uqPPhKz7NC+9zNwcWLn+qhk. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. [email protected]'s password: [email protected] ~ $ who Administrator pty1 2015-07-24 09:39 (::1)

安裝教材:

網上安裝教材很多,我就不贅述了。

在windows系統中通過cygwin安裝hadoop:http://my.oschina.net/u/570654/blog/112757

按照這篇安裝cygwin就可以。