Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39835
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 60
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-15 12:25
文章分类

全部博文(18)

文章存档

2018年(3)

2017年(3)

2016年(12)

我的朋友

分类: LINUX

2017-01-11 13:43:05

要求: A服务器访问B服务器,无需输入密码

 

在A和B服务器上,执行命令:ssh-keygen,之后一路回车

[oracle@fortune bijob]$ ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/home/oracle/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/oracle/.ssh/id_rsa.

Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.

The key fingerprint is:

56:5d:32:4a:19:2a:7f:54:b8:01:2c:52:80:28:54:7a oracle@fortune

 

 

之后,将在 $HOME/.ssh/id_rsa.pub 传输到B服务器,

在B服务器上的$HOME/.ssh 目录:

cat id_rsa.pub >> $HOME/.ssh/authorized_keys

 

之后,在A服务器上,ssh B服务器ip,发现,无需输入密码即可访问

注释:

      如若还不能访问,请检查:

1.     设置文件和目录权限:

设置authorized_keys权限

$ chmod 600 authorized_keys 

设置.ssh目录权限

$ chmod 700 .ssh

要保证.ssh和authorized_keys都只有用户自己有写权限。否则验证无效。(今天就是遇到这个问题,找了好久问题所在),其实仔细想想,这样做是为了不会出现系统漏洞。

2.     A无密码访问B出现报错信息

登录系统报错,-bash: ulimit: open files: cannot modify limit: Operation not permitted

  Last login: Thu Aug 23 14:42:27 2012 from 10.6.90.41

  -bash: ulimit: open files: cannot modify limit: Operation not permitted

  -bash: ulimit: open files: cannot modify limit: Operation not permitted

 解决办法:

  vi  /etc/ssh/sshd_config

  把 UseLogin 设置为 yes,

  #UseLogin no

  UseLogin ye

  重启ssh服务

  service sshd restart

阅读(1123) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~