ssh免密码登录
2016-02-18 16:08
459 查看
在linux上生成密钥对,并把公钥放到远程linux上,实现密钥验证登陆
假如您的两台linux分别为A和B,在A上执行:
它在/home/chenlb下生成.ssh目录,.ssh下有id_rsa和id_rsa.pub。
.A机登录B机。
假如您的两台linux分别为A和B,在A上执行:
[root@localhost ~]# ssh-keygen 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: 00:8f:00:7f:4c:21:8b:48:0b:3a:04:30:7c:32:3f:b2 root@localhost.localdomain The key's randomart image is: +--[ RSA 2048]----+ |X+o +. | |*B.B + | |=.B + o | | o + . | | o . S | | E | | | | | | | +-----------------+
它在/home/chenlb下生成.ssh目录,.ssh下有id_rsa和id_rsa.pub。
cat .ssh/id_rsa.pub复制这些内容粘贴到B机器的 /root/.ssh/authorized_keys 文件里,此时B机器上若没有/root/.ssh 目录,则需要先创建,并修改其权限:
mkdir /root/.ssh chmod 700 /root/.ssh vi /root/.ssh/authorized_keysauthorized_keys的权限要是600。
chmod 600 .ssh/authorized_keys
.A机登录B机。
[chenlb@A ~]$ ssh 192.168.1.181就可以登录到B机器上了。
相关文章推荐
- Linux Generating SSH Keys
- Centos6 编译安装Python
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- CentOS 7系统配置上的变化解析
- CentOS下DB2数据库安装过程详解
- CentOS 6.3下编译安装Ruby 2.0笔记
- 在Centos 5.5 上编译安装mysql 5.5.9
- 在阿里云的CentOS环境中安装配置MySQL的教程
- perl脚本实现限制ssh最大登录次数(支持白名单)
- CentOS 6.5源码安装Erlang教程
- Centos下安装docker教程
- rsync ssh 数据同步分析
- 在CenOS系统下安装和配置Redis数据库的教程
- 搭建SSH时的思考和遇到的几个问题的解决方法
- centos 5.6 升级php到5.3的方法
- SSH 使用原理 与解释