cygwin安裝sshd服務並實現無密碼登錄

這篇文章主要是爲我在win7(64位)下搭建hadoop環境所準備的。首先參照在cygwin使用總結這篇文章在cygwin中安裝所必須得軟件包,然後如下進行操作:

sony@sony-VAIO~ $ ssh-host-config

*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Generating /etc/ssh_host_ecdsa_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) 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] 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: You appear to be running Windows XP 64bit, Windows 2003 Server,
*** Info: or later.  On these systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar 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: sony
*** Query: Reenter: sony

*** Warning: Privileged account 'sony' was specified,
*** Warning: but it does not have the necessary privileges.
*** Warning: Continuing, but will probably use a different account.
*** Warning: The specified account 'sony' does not have the
*** Warning: required permissions or group memberships. This may
*** Warning: cause problems if not corrected; continuing...
*** Query: Please enter the password for user 'sony':
*** Query: Reenter:


*** Info: The sshd service has been installed under the 'sony'
*** 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!

 $ net start sshd
發生系統錯誤 1069 --- 表示由於登錄失敗而無法啓動服務

解決方法:在cmd中輸入services.msc即可打開windows的服務,在服務中把密碼改對就可以了。
(在上面配置ssh的過程中我的用戶名是:sony 密碼是:123456)

sshd服務裝成功如下:

sony@sony-VAIO ~ $ net start sshd
CYGWIN sshd 服務正在啓動 .
CYGWIN sshd 服務已經啓動成功

接下來是配置無密碼登陸:

sony@sony-VAIO ~ $ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sony/.ssh/id_rsa):
Created directory '/home/sony/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/sony/.ssh/id_rsa.
Your public key has been saved in /home/sony/.ssh/id_rsa.pub.
The key fingerprint is:
e8:38:5e:e3:bb:cf:76:03:61:5f:f2:68:ed:a3:49:db sony@sony-VAIO
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|       .o . .    |
|      ..So *     |
|     o  . + o    |
|    o +  o..     |
|   . + o..o+o    |
|    . +=o.+oE.   |
+-----------------+

sony@sony-VAIO ~ $ cd .ssh/

sony@sony-VAIO ~/.ssh $ ls
id_rsa  id_rsa.pub

sony@sony-VAIO ~/.ssh $ cp id_rsa.pub authorized_keys

sony@sony-VAIO ~/.ssh $ ls
authorized_keys  id_rsa  id_rsa.pub

驗證如下:

sony@sony-VAIO ~/.ssh $ ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is 5f:21:b1:24:80:92:f6:af:3e:e3:a8:f9:cb:a4:4f:ec.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.

sony@sony-VAIO ~ $ who
sony     tty0         2011-11-25 15:42 (::1)

 

搞定 ~_~
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章