RHCE——配置和保护OPENSSH服务
来源:互联网 发布:淘宝代购网店怎么开 编辑:程序博客网 时间:2024/06/02 03:09
SSH(OpenSSH Secure Shell)
Secure Shell示例
远程连接到服务器上
[student@localhost 桌面]$ ssh root@xx.xx.xx.xxroot@120.24.222.231's password: Last login: Sun Jul 30 21:05:09 2017 from 223.11.69.68Welcome to Alibaba Cloud Elastic Compute Service !
W命令可现实当前登陆到计算机的用户列表。
显示那些用户使用了SSH的登陆位置,以及操作内容
[root@iZtoz99sjuwqcnZ ~]# w -f 21:23:01 up 2 days, 4:51, 4 users, load average: 0.00, 0.01, 0.05USER TTY LOGIN@ IDLE JCPU PCPU WHATroot tty1 五16 2days 8.93s 0.00s xinit /etc/X11/xinit/xinitrc --root pts/0 五16 2days 0.04s 0.00s mysql -u root -proot pts/1 21:05 17:25 0.03s 0.03s -bashroot pts/2 21:20 5.00s 0.03s 0.00s w -f
SSH主机密钥
SSH通过公钥加密的方式保持通信安全。
在本地的 ~/.ssh/known_hosts
存储着之前连接服务器的公钥
如果服务器的公钥发生改变,用户需要更新~/.ssh/known_hosts
才能继续登陆
主机ID存储在实体客户端系统上的~/.ssh/known_hosts
[student@localhost 桌面]$ cat ~/.ssh/known_hosts 120.24.222.231 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXN....
主机密钥存储在SSH服务器上的/etc/ssh/ssh_host_ecdsa_key
[root@iZtoz99sjuwqcnZ ssh]# cat /etc/ssh/ssh_host_ecdsa_key-----BEGIN EC PRIVATE KEY-----MHcCAQEEIHlZ3jd8bCw/xn4/00tgtLGGfI52Lqt83Z6Y1RBy9BiuoAoGCCqGSM49AwEHoUQDQgAEtLBBvKVSy4mpj+AI4of09fNtNZ8ky5JUhiKzLQ5+y6SZ85P4SJzfJ7K6hHOD6XpaFcXg51MqI45icAVuFgkKuQ==-----END EC PRIVATE KEY-----
配置基于SSH密钥的身份验证
使用ssh-keygen命令生成密钥。这将生成密钥~/.ssh/id_rsa
和~/.ssh/id_rsa.pub
.
SSH密钥演示
- 以Student的身份创建密钥对
- 将SSH公钥发送到服务器上账户上
- 运行SSH登陆命令,则不需要密码
[student@localhost 桌面]$ ssh-keygen[student@localhost 桌面]$ ssh-copy-id root@XX.xx.xx.xx[student@localhost 桌面]$ ssh root@xx.xx.xx.xx
[student@localhost 桌面]$ ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/home/student/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/student/.ssh/id_rsa.Your public key has been saved in /home/student/.ssh/id_rsa.pub.The key fingerprint is:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xxstudent@localhost.localdomainThe key's randomart image is:+--[ RSA 2048]----+| || . . || . o . . || o o * o || . . O S . || = + o || . . + || .o + . || E.o |+-----------------+[student@localhost 桌面]$ ssh-copy-id root@XX.xx.xx.xx/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysroot@xx.xx.xx.xx's password: Number of key(s) added: 1Now try logging into the machine, with: "ssh 'root@xx.xx.xx.xx'"and check to make sure that only the key(s) you wanted were added.[student@localhost 桌面]$ ssh root@xx.xx.xx.xxLast login: Sun Jul 30 21:44:34 2017 from 223.11.69.68Welcome to Alibaba Cloud Elastic Compute Service !
自定义SSH服务配置
配置文件在 /etc/ssh/sshd_config
中,可以修改OpenSSH服务的各方面
禁止root用户使用SSH登陆
将默认的注释的许可root登陆去掉注释,然后在参数上改为no
[root@localhost ~]# vim /etc/ssh/sshd_config #Permitrootlogin yes //将这条语句改成下一条语句Permitrootlogin no[root@localhost ~]# systemctl restart sshd.service
另一选项是仅允许root身份进行基于密钥的ssh登陆
[root@localhost ~]# vim /etc/ssh/sshd_config #Permitrootlogin yes //将这条语句改成下一条语句Permitrootlogin without-password[root@localhost ~]# systemctl restart sshd.service
禁止使用SSH进行密码身份验证
[root@localhost ~]# vim /etc/ssh/sshd_config PasswordAuthentication yes //将这条语句改成下一条语句PasswordAuthentication no[root@localhost ~]# systemctl restart sshd.service
sshd_config参数解释
更改登陆端口
说明主机的 Private Key 放置的档案
安全设定项目
登入设定部分
认证部分
sshd_config具体配置
阅读全文
0 0
- RHCE——配置和保护OPENSSH服务
- 1-9配置和保护openssh服务
- RHEL八(配置和保护openssh服务)
- RHCE——控制服务和守护进程
- RHCE——配置链路聚合和桥接
- RHCE——分析和存储日志
- RHCE——安装和更新软件包
- linux系统命令行基本操作——系统服务的控制和openssh-server
- 学习运维——系统服务控制、openssh
- OpenSSH服务——基于密钥的ssh认证实现
- OpenSSH服务
- OpenSSH服务
- RHCE练习题 6. 配置本地邮件服务 两种方法
- Fedora中安装和配置OpenSSH
- Ubuntu下安装和配置OpenSSH
- openSSH Server 手动安装和配置
- Fedora22下telnet和openssh的配置
- yum配置---RHCE第一步
- JavaSE-Headfirst Java笔记
- 19个javascript提高编码效率技巧
- 快乐数
- JavaScript的内置对象 2017-07-31
- hdu2095 find your present (2)(C语言
- RHCE——配置和保护OPENSSH服务
- Objective
- Guava Cache 数据变化实现回调的监听器RemovalListener
- Java数值类型提升机制
- 感想一篇and博客开张
- DC -19 :树树树02(接DC
- java 方法中的形参传值
- 在java中 i++和++i有什么区别
- UVA 10870 Recurrences 矩阵连乘 快速幂取模