码迷,mamicode.com
首页 > Windows程序 > 详细

windows putty 链接到 linux 免密码

时间:2015-01-28 00:45:54      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:

目标:system1透过ssh连接到system2电脑

技术分享

  • 生成 private key (id_rsa) & public key (id_rsa.pub)
  • id_rsa是system1要用的,例如windows端
  • id_rsa.pub是你要连过去system2要用的, 此服务器必须安装openssh-server服务(sshd)
  • 把id_rsa.pub appendsystem2的 ~/.ssh/authorized_keys 文件里面
  • 并要清楚登入服务器的username,例如root
  • 找一台可以运行 ssh-keygen 的环境, windows可用Cygwin

步骤如下:

# ssh-keygen -t rsa
Enter file in which to save the key (~/.ssh/id_rsa): 
Created directory ‘~/.ssh‘.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is:
1c:fe:8d:10:b5:32:09:95:51:48:df:45:ef:74:5d:dc henry@db0222da7529
The key‘s randomart image is:
+--[ RSA 2048]----+
|      .o+=o  .o.o|
|       .o+ o . .E|
|        * o .   =|
|       o =     o.|
|        S       .|
|         o o     |
|          o .    |
|                 |
|                 |
+-----------------+

ssh-keygen的参数说明:

-t type
  Specifies the type of key to create. The possible values are
  ``rsa1‘‘ for protocol version 1 and ``dsa‘‘, ``ecdsa‘‘ or ``rsa‘‘
  for protocol version 2.
# cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys

注意: 用putty自带的PUTTYGEN.EXE生成会不兼容OpenSSH,从而会导致登录时出现server refused our key错误

做法: 把private key(id_rsa)给拷贝出来,我是用vim或cat来开启id_rsa文件然后用鼠标按右键拷到windows下的剪贴板, 存到一个文本给PUTTYGEN.EXE File/Load private key使用. 接着点击Save private key, 此档案等下要用.

技术分享

1.开启putty.exe, 设定Connection/data/Auto-login username, 这里我是用root来登入

2.SSH/Auth/Private key file for authentication:点击Browser选择到你保存私钥(.pkk)的文件, 就是 Save private key 的那个档案.

技术分享

 

windows putty 链接到 linux 免密码

标签:

原文地址:http://www.cnblogs.com/jHenry/p/4254104.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!