登陆ssh不需要使用密码
2010-02-22 09:40
267 查看
每次登陆ssh都需要输入用户名和密码,我想作一个双机的互备。考虑密码隔断时间都需要修改,那我的备份程序也需要修改。因此就想使用不需要密码用ssh登陆机器,这样我就可以使用rsync,scp,rexec等命令来做的远程备份了。
方法如下:
假设A,B两服务器,现在需要在A机上用root登陆B机,而不需要输入密码,那我们可按照下面的步骤来做:
1)在A机上生成钥匙对
A# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 mlsx@mlsx
这样,会生成id_rsa,和id_rsa.pub,其中id_rsa是密钥,id_rsa.pub是公钥。
2)把在A机生成的id_rsa.pub拷贝到B机上。
A# scp id_rsa.pub root@B:/tmp
3)用root帐号登陆B机,进入其主目录,创建authorized_keys文件,并设置好权限
B# cd ~/.ssh
#cat /tmp/id_rsa.pub >>authorized_keys
#chmod 400 authorized_keys
4)测试
在A机上转到root帐号,尝试登录B机。看看是不是不要密码.
5)authorized_keys文件的权限很重要,如果设置为777,那么登录的时候,还是需要提供密码的。
本方法在Fedora Core 2 和RedFlag Desktop 4.1上测试通过。
有什么问题,欢迎交流!
方法如下:
假设A,B两服务器,现在需要在A机上用root登陆B机,而不需要输入密码,那我们可按照下面的步骤来做:
1)在A机上生成钥匙对
A# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 mlsx@mlsx
这样,会生成id_rsa,和id_rsa.pub,其中id_rsa是密钥,id_rsa.pub是公钥。
2)把在A机生成的id_rsa.pub拷贝到B机上。
A# scp id_rsa.pub root@B:/tmp
3)用root帐号登陆B机,进入其主目录,创建authorized_keys文件,并设置好权限
B# cd ~/.ssh
#cat /tmp/id_rsa.pub >>authorized_keys
#chmod 400 authorized_keys
4)测试
在A机上转到root帐号,尝试登录B机。看看是不是不要密码.
5)authorized_keys文件的权限很重要,如果设置为777,那么登录的时候,还是需要提供密码的。
本方法在Fedora Core 2 和RedFlag Desktop 4.1上测试通过。
有什么问题,欢迎交流!
相关文章推荐
- 【转载】登陆ssh不需要使用密码
- 登陆ssh不需要使用密码
- mac上使用终端配置ssh,使用密码/或者免密码登陆Linux服务器
- ssh使用无密码登陆
- ubuntu系统使用SSH免密码登陆
- sync,ssh,expect配合使用备份不需要输入密码
- Linux下通过SSH方式登陆不需要密码的方法 SSH without password
- UNIX系统下,设置ssh登陆不需要密码
- ubuntu系统使用SSH免密码登陆
- 使用ssh-keygen,实现免密码登陆linux
- 使用SSH证书(不要密码)登陆远程服务器
- 使用ssh private key 免密码登陆服务器的流程(Amazon 的EMR 采用了此方式登陆服务器)
- 使用ssh-keygen,实现免密码登陆linux的方法
- 使用SSH证书(不要密码)登陆远程服务器
- ssh 免密码/不需要密码登陆/shell ssh自动登陆
- Linux下使用SSH非交互式远程执行命令脚本---ssh无密码登陆
- win平台使用secureCRT通过ssh免密码登陆linux
- 使用SSH免密码登陆
- linux 使用java编写ssh登陆主机 输入密码登陆并执行命令(jsch)
- ssh登陆不需要密码(配置信任有关系)