安装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 ~
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值