安裝cygwin並配置ssh免密碼登陸

1.下載cygwin,並安裝Net類別下的OpenSSH和OpenSSL;
設置環境變量,把 C:/cygwin/bin;C:/cygwin/usr/bin 加入到系統環境變量的Path中;
2.管理員身份打開cygwin,輸入

$ ssh-host-config

Should StrictModes be used?
“StrictModes”設置ssh在接收登錄請求之前是否檢查用戶家目錄和rhosts文件的權限和所有權。這通常是必要的,因爲新手經常會把自己的目錄和文件設成任何人都有寫權限。
Should privilege separation be used? (yes/no) 選擇:no,

 Copying skeleton files.
These files are for the users to personalise their cygwin experience.

They will never be overwritten nor automatically updated.

'./.bashrc' -> '/home/Administrator//.bashrc'
'./.bash_profile' -> '/home/Administrator//.bash_profile'
'./.inputrc' -> '/home/Administrator//.inputrc'
'./.profile' -> '/home/Administrator//.profile'

Administrator@172-22-1-39 ~
$ ssh-host-config

*** Info: Generating missing SSH host keys
ssh-keygen: generating new host keys: 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) ^C

Administrator@172-22-1-39 ~
$ 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/READ                                                                                                                ME.privsep.
*** Query: Should privilege separation be used? (yes/no) no
*** Info: Updating /etc/sshd_config file

*** Info: Sshd service is already installed.

*** Info: Host configuration finished. Have fun!

Administrator@172-22-1-39 ~
$ cygrunsrv --start sshd

Administrator@172-22-1-39 ~
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/Administrator/.ssh/id_rsa):
Created directory '/home/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/Administrator/.ssh/id_rsa.
Your public key has been saved in /home/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:nLcKHtpT62vqKmMEj3DQAesn5OsmT5u4yLxMjRJ9e7I Administrator@172-22-1-39
The key's randomart image is:
+---[RSA 2048]----+
|.o..             |
|...              |
|.o               |
|*..    . .       |
|oO...   S .      |
|..O. .  .. .     |
|.=..o +. ..      |
|X++o B.oo.       |
|*X=oEo==+.       |
+----[SHA256]-----+

Administrator@172-22-1-39 ~
$  cd ~/.ssh

Administrator@172-22-1-39 ~/.ssh
$ ls -l
總用量 5
-rw------- 1 Administrator None 1679 3月  14 16:53 id_rsa
-rw-r--r-- 1 Administrator None  407 3月  14 16:53 id_rsa.pub

Administrator@172-22-1-39 ~/.ssh
$ cat id_rsa.pub >> authorized_keys

Administrator@172-22-1-39 ~/.ssh
$ ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:w/Ut1DvANoNYML1/RcIDMm24ToVguXc9R6F67jKmb3E.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.

Administrator@172-22-1-39 ~
$ ssh localhost
Last login: Mon Mar 14 08:54:32 2016 from ::1

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