快捷搜索:  

redhat es 5.5 安装无密码登陆的openssh

redhat es 5.5 安装无密码登陆的openssh(系统自带)

1. 确保sshd正常启用

查看 /etc/rc.conf 是否存在 sshd_enable=”YES” ;如果没有添加进去并人工方式启动#/etc/rc.d/sshd start ;然后查询 22端口是否启动:#sockstat -4l

root sshd 8085 4 tcp4 *:22 *:*

2. 配置 OpenSSH

针对 OpenSSH 服务程序和客户端的系统级配置文件在 /etc/ssh 目录中。ssh_config 用于配置客户端的设定, 而 sshd_config 则用于配置服务器端。

现在来说通过配置 OpenSSH 使服务器接受公钥(public-key)认证。sshd_config 这个文件指定的一些默认值都是生效的,虽然这些选项被注释掉了,如果你想改变默认值的话,那就取消注释更改值或者直接添加相同的选项和值覆盖默认值的作用。

#vi /etc/ssh/sshd_config

#默认 SSH 端口为 22 ,如果需要可以更改
Port 22

#仅接受版本2的密钥,默认值
Protocol 2

#绝对不要允许 root 用户直接通过网络登录,默认值
PermitRootLogin no
StrictModes yes
MaxAuthTries 6

#启用公钥认证
RSAAuthentication no #
默认值为 yes
PubkeyAuthentication yes
#默认值

#不使用基于主机的认证,加强 OpenSSH 的安全性
RhostsRSAAuthentication no #
默认值
HostbasedAuthentication no #
默认值
IgnoreUserKnownHosts yes #
默认值为 no
PermitEmptyPassword no #
默认值

#禁用 PAM 认证即口令形式认证 默认值为yes
ChallengeResponseAuthentication no

编辑完成后重启 sshd 进程:`#/etc/rc.d/sshd restart` Linux 系统上一般是 `/etc/init.d/ssh restart`

注意:因为是通过 SSH 口令认证的方式连接到服务器来操作,操作ChallengeResponseAuthentication 这个选项改为 no 后不能退出登陆,继续下面操作,或者也可以在成功验证了密钥后再改这个选项。以免出错导致无法远程SSH登录服务器。

3. 生成公钥(public key)和私钥(private key

用需要生成密钥的用户通过 SSH 密码认证的方式登录
FreeBSD
使用 ssh-keygen 来生成 DSA RSA 密钥对用于验证用户的身份:

% ssh-keygen -t rsa
Generating public/private dsa key pair.

#不输入即使用默认
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory ‘/home/user/.ssh’.

#密钥的密码,需要输入并记住
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
bb:48:db:f2:93:57:80:b6:aa:bc:f5:d5:ba:8f:79:17 user@host.example.com

ssh-keygen

顶(2)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论

  • ^