当前位置: 首页 >> 网络协议与安全 >> Cygwin上ssh服务的putty自动登录问题
 

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

作者:      来源:http://blog.csdn.net/yjz0065     发表时间:2007-04-03     浏览次数:      字号:    

一:首先安装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

责任编辑 webmaster

 
 
 
 
 
评论更多>>
 
 
 
发表
 
姓名: QQ:
性别: MSN:
E-mail: 主页:
评分: 1 2 3 4 5
评论内容:
验证码:
  
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表网友个人观点,与本网站立场无关。
  •