---
title: "SSH 无密码认证（RSA/DSA认证）"
author: "iammonster"
date: "2010-03-22T14:13:55Z"
tags: []
categories: ["操作系统"]
slug: "ssh-rsa-dsa"
draft: false
lastmod: "2010-03-22T14:13:55Z"
id: 621309
url: "https://jiajun.iteye.com/blog/621309"
---

今天配置hadoop过程中发现，ssh localhost 配置RSA认证（要求无密码），不然要输入三次密码启动服务。

 

但是郁闷的是我执行了下面的命令却无效

```
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/youruser/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/youruser/.ssh/id_rsa.
Your public key has been saved in /home/youruser/.ssh/id_rsa.pub.
The key fingerprint is:
11:11:35:75:40:c5:nh:2d:7u:96:c3:rr:81:86:67:53 youruser@yourhost
```

 然后我ssh localhost 却要求输入密码

 

没办法，我找另外个机器 配置ssh认证，记得以前是配置过的，怎么会失效呢？结果也没成功，最后无奈之下：删除了机器上所有的认证文件：

```
rm ~/.ssh/*
```

 重新配置，就好了，哎，又是一次教训，上次配置时候没有做笔记，这次就记下。

 

当然重新温习了一下：RSA/DSA认证，还是有好处的，记忆中模糊了。

 

下面有三篇好文章，记得看一下哦，人家讲解的通俗易懂，考虑的又比较全面：

http://www.ibm.com/developerworks/cn/linux/security/openssh/part1/index.html

http://www.ibm.com/developerworks/cn/linux/security/openssh/part2/index.html

http://www.ibm.com/developerworks/cn/linux/security/openssh/part3/index.html

 

再一个就是网上有些资料，有误导作用，千万小心了，举例：

修改 /etc/ssh/sshd\_conf 文件

PasswordAuthentication yes-&gt;no

如果你的服务器不在本地，千万不能这样做，万一当前的ssh链接中断，那你得麻烦机房的人给你修改配置了。小心起见，我在本地机器上试验了，RAS认证没弄好，密码验证又禁止了，你哭吧。呵呵