首页 > 代码库 > windows putty 链接到 linux 免密码
windows putty 链接到 linux 免密码
目标: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 append到system2的 ~/.ssh/authorized_keys 文件里面
- 并要清楚登入服务器的username,例如root
- 找一台可以运行 ssh-keygen 的环境, windows可用Cygwin
步骤如下:
# ssh-keygen -t rsaEnter 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@db0222da7529The 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 免密码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。