CentOS 5.6 x86 64 配置SSH无密码登陆

刚在做Oracle的备份,脚本中用到了scp,需要把服务器的数据cp到备份服务器上,需要配置oracle数据库服务器可以通过db_backup用户无密码登陆到备份服务器上,随便把ssh无密码登陆的配置步骤记下来了,下面是具体工程:

环境:

oracle数据库服务器:10.20.220.247

备份服务器:10.20.220.25

备份用户:db_backup

步骤:

1.在10.20.220.25上新建db_backup用户,指定家目录为/data/backup并设置密码
[root@localhost ~]# useradd db_backup -d /data/backup
[root@localhost ~]# passwd db_backup
Changing password for user db_backup.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

2.确认sshd的配置文件的认证模块已打开

vi /etc/ssh/sshd_config

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys

把上面三行的注释去掉

重启ssh服务

3.在10.20.220.247上

A.#ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
a4:a2:8e:58:e5:d3:38:92:00:c4:bf:a5:f9:67:af:ed root@localhost.localdomain

B.#cd .ssh/

#mv id_dsa.pub authorized_keys

#chmod 600 authorized_keys

4.在10.20.220.25上以db_backup登陆执行ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa

[db_backup@localhost ~]$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
Generating public/private dsa key pair.
Created directory '/data/backup/.ssh'.
Your identification has been saved in /data/backup/.ssh/id_dsa.
Your public key has been saved in /data/backup/.ssh/id_dsa.pub.
The key fingerprint is:
13:03:fd:46:2a:70:1d:a8:01:33:7b:c6:00:59:d2:a9 db_backup@localhost

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/f67d5c2033a63939f8eb8fb933517f58.html