Centos6.2 构建SSH 密钥对验证登录
2012-11-22 00:45
549 查看
Centos6.2 构建SSH远程登录
centos 默认以安装SSH ,配置文件 在/etc/ssh/ 目录 下 有ssh_config 和sshd_config
ssd_config 是客服端配置文件 sshd_config 是服务端配置文件
一:SSH默认是只有ROOT用户可以登录,怎么样 开启普通用户:xiang 可以用SSH登录了? 同时禁用ROOT登录?
vi编辑 sshd_config 文件
[root@localhost ~]# vi /etc/ssh/sshd_config
PermitRootLogin no #禁用root用户登录
二:构建密钥对验证SSH登录系统
1:客户机配置(192.168.1.111)
[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): # 直接回车
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): # 密码短信 用于保护私钥文件
Enter same passphrase again:
Passphrases do not match. Try 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:
6d:eb:29:87:e2:f9:be:84:9d:a2:c0:51:e9:66:4c:ea root@localhost.localdomain #会生成两个文件
[root@localhost ~]# ll -h ~/.ssh/
总计 8.0K
-rw------- 1 root root 1.8K 11-21 23:24 id_rsa
-rw-r--r-- 1 root root 408 11-21 23:24 id_rsa.pub
id_rsa 是私钥 id_rsa.pub 是公钥
上传公钥到给服务器
2:服务器配置(192.168.1.114)
[root@localhost ~]# scp root@192.168.1.111:/root/.ssh/id_rsa.pub ./
root@192.168.1.111's password:
id_rsa.pub 100% 408 0.4KB/s 00:00
[root@localhost ~]#
[root@localhost ~]# cp id_rsa.pub ~xiang005/.ssh/
[root@localhost .ssh]# ll
总用量 4
-rw-r--r-- 1 root root 408 11月 22 00:08 id_rsa.pub
[root@localhost .ssh]# cat id_rsa.pub > authorized_keys
[root@localhost .ssh]# vi /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
[root@localhost .ssh]# service sshd restart
停止 sshd:[确定]
正在启动 sshd:[确定]
3:在客服机上验证
[root@localhost .ssh]# ssh xiang005@192.168.1.114
Enter passphrase for key '/root/.ssh/id_rsa':
Last login: Wed Nov 21 23:14:53 2012 from 192.168.1.115
[xiang005@localhost ~]$
成功~~!
在secureCRT 中用公钥登录
把私钥:id_rsa 放到电脑桌面。
这张图片有点问题,应该是选 id_rsa 这个文件 ,我之前把id_rsa 改成了id_rsa.pub
是不行的。 又改回来了。
完成~~!搞定
本文出自 “东方之龙” 博客,请务必保留此出处http://xiang005.blog.51cto.com/6689/1066681
centos 默认以安装SSH ,配置文件 在/etc/ssh/ 目录 下 有ssh_config 和sshd_config
ssd_config 是客服端配置文件 sshd_config 是服务端配置文件
一:SSH默认是只有ROOT用户可以登录,怎么样 开启普通用户:xiang 可以用SSH登录了? 同时禁用ROOT登录?
vi编辑 sshd_config 文件
[root@localhost ~]# vi /etc/ssh/sshd_config
PermitRootLogin no #禁用root用户登录
二:构建密钥对验证SSH登录系统
1:客户机配置(192.168.1.111)
[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): # 直接回车
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): # 密码短信 用于保护私钥文件
Enter same passphrase again:
Passphrases do not match. Try 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:
6d:eb:29:87:e2:f9:be:84:9d:a2:c0:51:e9:66:4c:ea root@localhost.localdomain #会生成两个文件
[root@localhost ~]# ll -h ~/.ssh/
总计 8.0K
-rw------- 1 root root 1.8K 11-21 23:24 id_rsa
-rw-r--r-- 1 root root 408 11-21 23:24 id_rsa.pub
id_rsa 是私钥 id_rsa.pub 是公钥
上传公钥到给服务器
2:服务器配置(192.168.1.114)
[root@localhost ~]# scp root@192.168.1.111:/root/.ssh/id_rsa.pub ./
root@192.168.1.111's password:
id_rsa.pub 100% 408 0.4KB/s 00:00
[root@localhost ~]#
[root@localhost ~]# cp id_rsa.pub ~xiang005/.ssh/
[root@localhost .ssh]# ll
总用量 4
-rw-r--r-- 1 root root 408 11月 22 00:08 id_rsa.pub
[root@localhost .ssh]# cat id_rsa.pub > authorized_keys
[root@localhost .ssh]# vi /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
[root@localhost .ssh]# service sshd restart
停止 sshd:[确定]
正在启动 sshd:[确定]
3:在客服机上验证
[root@localhost .ssh]# ssh xiang005@192.168.1.114
Enter passphrase for key '/root/.ssh/id_rsa':
Last login: Wed Nov 21 23:14:53 2012 from 192.168.1.115
[xiang005@localhost ~]$
成功~~!
在secureCRT 中用公钥登录
把私钥:id_rsa 放到电脑桌面。
这张图片有点问题,应该是选 id_rsa 这个文件 ,我之前把id_rsa 改成了id_rsa.pub
是不行的。 又改回来了。
完成~~!搞定
本文出自 “东方之龙” 博客,请务必保留此出处http://xiang005.blog.51cto.com/6689/1066681
相关文章推荐
- Centos使用密钥对验证登录SSH
- Openssh服务配置:控制用户登录 构建密钥对验证ssh
- CentOS更改ssh登录失败验证次数
- ssh免密码登录 用密钥验证
- 天龙盖地虎 宝塔镇河妖——构建密钥对验证的SSH
- CentOS6.5 下SSH密钥登录详解
- SSH密钥登录让VPS下centos服务器更安全
- 构建密钥对验证的SSH体系
- SSH远程登录的密钥验证授权机制
- 为CentOS配置SSH证书登录验证
- 构建密钥对验证的ssh体系
- 如何构建密钥对验证的SSH体系
- Centos7 SSH密钥登陆及密码密钥双重验证
- [CentOS] SSH 免密钥登录
- Linux启动或禁止SSH用户及IP的登录,只允许密钥验证登录模式
- 配置Centos7 SSH密钥登陆及密码密钥双重验证
- ssh免密码登录的最佳实践(Ubuntu 16.4 + CentOs 6 中验证通过)
- linux redhat6.5 构建SSH服务及SSH构建密钥对验证
- 为CentOS配置SSH证书登录验证
- ssh 密钥验证登录