Cygwin上的ssh服务的putty自动登录问题

 一:首先安装CYGWIN
  1. OS修改環境變數:path增加d:/cygwin/bin
  2. OS增加環境變數:CYGWIN=ntsec tty
  3. Cygwin安裝必要的套件:OpenSSHcygrunsrv
  4. Cygwin設定OpenSSH:
    1. 執行 ssh-host-config
    2. Should privilege separation be used? (yes/no) :yes
    3. Should this script create a local user 'sshd' on this machine? (yes/no) :yes
    4. Do you want to install sshd as service? (yes/no) :yes
    5. Default is "ntsec" . CYGWIN=ntsec tty
  5. 手動啟動OpenSSH服務:net start sshd
  6. 手動關閉OpenSSH服務:net stop sshd
     
二:PUTTY的自动登陆

先产生公/私钥

1、用自己的用户名登陆到服务器,然后:
ssh-keygen -t rsa
生成的公/私钥文件缺省在 ~/.ssh/ 下
进入.ssh目录
mv id_rsa.pub authorized_keys  // (更改为系统默认的公钥文件名)
将id_rsa文件(私钥)传到windows机器下,将原来的id_rsa文件删除

2、用PUTTYGEN.EXE转换id_rsa文件为putty的格式
菜单:Conversions/ImportKey ,选中id_rsa文件
直接点"Save private key"按钮将新格式的文件保存到硬盘,如D:/mykey.ppk

然后再建立一个putty的快捷方式,格式如下:

putty -i D:/mykey.ppk -l yourname server's IP

好了~~~
三:实施过程

netoearth@yjz0065 ~
$ ssh-host-config
Overwrite existing /etc/ssh_config file? (yes/no) yes
Generating /etc/ssh_config file
Overwrite existing /etc/sshd_config file? (yes/no) yes
Privilege separation is set to yes by default since OpenSSH 3.3.
However, this requires a non-privileged account called 'sshd'.
For more info on privilege separation read /usr/share/doc/openssh/README.privsep
.

Should privilege separation be used? (yes/no) yes
Generating /etc/sshd_config file


Warning: The following functions require administrator privileges!

Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no) yes

You appear to be running Windows 2003 Server or later.  On 2003 and
later systems, it's not possible to use the LocalSystem account
if sshd should allow passwordless logon (e. g. public key authentication).
If you want to enable that functionality, it's required to create a new
account 'sshd_server' with special privileges, which is then used to run
the sshd service under.

Should this script create a new local account 'sshd_server' which has
the required privileges? (yes/no) yes

Please enter a password for new user 'sshd_server'.  Please be sure that
this password matches the password rules given on your system.
Entering no password will exit the configuration.  PASSWORD=password

User 'sshd_server' has been created with password 'password'.
If you change the password, please keep in mind to change the password
for the sshd service, too.

Also keep in mind that the user sshd_server needs read permissions on all
users' .ssh/authorized_keys file to allow public key authentication for
these users!.  (Re-)running ssh-user-config for each user will set the
required permissions correctly.


Which value should the environment variable CYGWIN have when
sshd starts? It's recommended to set at least "ntsec" to be
able to change user context without password.
Default is "ntsec".  CYGWIN=netec

The service has been installed under sshd_server account.
To start the service, call `net start sshd' or `cygrunsrv -S sshd'.

Host configuration finished. Have fun!

netoearth@yjz0065 ~
$ net start sshd
CYGWIN sshd 服务正在启动 .
CYGWIN sshd 服务已经启动成功。

netoearth@yjz0065 ~
$ ssh-keygen.exe -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/cygdrive/d/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /cygdrive/d/.ssh/id_dsa.
Your public key has been saved in /cygdrive/d/.ssh/id_dsa.pub.
The key fingerprint is:
10:f1:b0:59:60:9d:ef:a7:ab:b3:36:8d:01:63:c4:6f netoearth@yjz0065

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值