Chinaunix首页 | 论坛 | 博客
  • 博客访问: 578486
  • 博文数量: 43
  • 博客积分: 10257
  • 博客等级: 上将
  • 技术积分: 480
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-06 02:16
文章分类

全部博文(43)

文章存档

2011年(5)

2010年(12)

2009年(6)

2008年(20)

分类: LINUX

2008-06-04 14:09:17

如今很多系统管理员都喜欢使用SecureCRT和PuTTY登录到服务器上管理,这里介绍下如何使用密钥来进行登录认证过程。

1. 使用PuTTY客户端

先到PuTTY网站去下载putty.exe, psftp.exe, puttygen.exe

Link:

Binaries

The latest release version (beta 0.60). This will generally be a version I think is reasonably likely to work well. If you have a problem with the release version, it might be worth trying out the latest development snapshot (below) to see if I've already fixed the bug, before reporting it to me.

For Windows 95, 98, ME, NT, 2000, XP and Vista on Intel x86
PuTTY:
PuTTYtel:
PSCP:
PSFTP:
Plink:
Pageant:
PuTTYgen:

 

1.1 使用puttygen.exe生成密钥

 
puttygen.exe 运行界面
 
 
生成密钥过程
 
 
保存共钥与私钥
 
密钥也可以添加passphrase来保护你的密钥。
 
 
 
1.2 使用psftp.exe将公钥上传到服务器上
 

将公钥上传到服务器

打开psftp.exe,然后使用open来打开指定的主机,这里是我虚拟机上的IP:192.168.32.227, 接着使用put命令上传公钥到服务器上,(注意:公钥必须要在psftp.exe运行的当前目录)

 

1.3 使用putty.exe登录到服务器上进行设置

登录到服务器上进行设置

使用putty.exe登录到服务器上,将刚刚上传的公钥移动到/root或用户目录的.ssh目录下,我这里是root用户。如果没有.ssh目录存在,则先创建.ssh目录。并且设置目录权限为所有者读写和执行,其他的都没有任何权限。这一步一定要执行,否则会使密钥无效。

[root@lvdbing.net]#mkdir .ssh
[root@lvdbing.net]#chmod 700 .ssh

然后进入.ssh目录,执行以下命令:

[root@lvdbing.net .ssh]ssh-keygen -i -f Public >authorized_keys
[root@lvdbing.net .ssh]chmod 600 authorized_keys

以上是把上传的公钥转换成Openssh可以认的公钥格式,否则使用putty.exe将连接不上。

然后也要把文件authorized_keys 权限设置为所有者读写和执行,其他的都没有任何权限(600)。这一步一定要执行,否则会使密钥无效。

 
1.4 使用putty.exe测试连接
 
 
打开putty.exe
 
 
指定私钥地址
 
 
登录成功
 
阅读(8612) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~