全面分析RHCE7(红帽认证工程师)考试题目之 ----SSH篇

管理SSH服务(远程链接服务)vim

一,ssh服务经常使用配置参数 /etc/ssh/sshd_config服务器

注意:修改端口时要确保SELinux 不是 Enforcingdom

[root@test13 ~]# vim /etc/ssh/sshd_config ssh

17 Port 2233tcp

19 ListenAddress 192.168.4.13ide

[root@test13 ~]# systemctl restart sshd加密

[root@test13 ~]# netstat -pantu | grep sshdspa

tcp    0    0 192.168.4.13:2233    0.0.0.0:*          LISTEN      4257/sshd  rest


[root@test13 ~]# vim /etc/ssh/sshd_config orm

19 #ListenAddress 192.168.4.13

[root@test13 ~]# systemctl restart sshd

[root@test13 ~]# netstat -pantu | grep sshd

tcp    0    0 0.0.0.0:2233        0.0.0.0:*           LISTEN      4487/sshd  


[root@test13 ~]# vim /etc/ssh/sshd_config 


48 #LoginGraceTime 2m//登陆限时

51 #MaxAuthTries 6//每次链接最多认证次数

#运程登陆输入密码错误6次 两分钟不容许登陆

129 #UseDNS yes//解析客户机地址


二,黑白名单

白名单(在白名单列表里的用户能够链接)

AllowUsers 用户名@客户端地址 用户名

AllowGroups 用户名组名1 用户名组名2

黑名单(只有在黑名单列表的用户不能够链接)

DenyUsers 用户名@客户端地址 用户名

DenyGroups 用户名组名1 用户名组名2


三,修改用户登陆认证方式:

口令认证登陆(密码登陆)

检查登陆用户的口令是否一致

密钥认证登陆(公钥加密 私钥解密)

client:

1,建立密钥对

2,把公钥传给ssh服务器

[root@room1pc32 桌面]# ssh-keygen 

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: 

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:

6f:b4:75:af:e5:60:79:d6:cd:36:c8:c8:7b:17:8c:e2 root@room1pc32.tedu.cn

The key's randomart image is:

+--[ RSA 2048]----------+

|                                      |

|                                      |

|                                      |

|                                      |

|        S . . +                    |

|         o.+oo.*o              |

|          =o.o+.@             |

|         . E.o X.                |

|           .. o .                    |

+------------------------------+


sshd:

包ssh服务认证方式修改成密钥认证方式

[root@room1pc32 桌面]# ls ~/.ssh/

id_rsa  id_rsa.pub

[root@test12 ~]# ls ~/.ssh/

ls: 没法访问/root/.ssh/: 没有那个文件或目录

[root@room1pc32 桌面]# ssh-copy-id root@192.168.4.12

[root@test12 ~]# ls ~/.ssh/

authorized_keys

[root@room1pc32 桌面]# ssh-add 

Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

[root@room1pc32 桌面]# ssh -X root@192.168.4.12

Last login: Tue Jan  2 21:30:50 2018 from 192.168.4.254



关闭口令登陆

[root@test12 ~]# vim /etc/ssh/sshd_config 

79 PasswordAuthentication no

[root@test12 ~]# systemctl restart sshd


关闭口令登陆后 若是其余主机想要访问的话 能够将本机的私钥访问

[root@room1pc32 桌面]# scp ~/.ssh/id_rsa 192.168.4.13:/root/.ssh/

[root@room1pc32 桌面]# ssh -X root@192.168.4.13

[root@test13 ~]# ls ~/.ssh/

id_rsa  known_hosts

[root@test13 ~]# ssh -X root@192.168.4.12

Last login: Tue Jan  2 21:46:08 2018 from 192.168.4.13

[root@test12 ~]# exit


四,客户端链接ssh服务

ssh ssh服务器地址   访问21端口 root用户

ssh 用户名@ssh服务器地址访问21端口

ssh -X -p 端口号 用户名@ssh服务器地址


*在RHCE的考试过程必定不要一直在虚拟机界面操做 必定是使用ssh远程链接两台虚拟来完成考试

在RHCE的考试中有一道考试题目是:

配置SSH访问

按如下要求配置 SSH 访问:

  • 用户可以从域 example.com(这个域名考试会改变) 内的客户端 SSH 远程访问您的两个虚拟机系统

  • 在域 my133t.org (这个域名考试会改变) 内的客户端不能访问您的两个虚拟机系统

        咱们须要作的是在俩台虚拟机上配置黑白名单 具体操做以下

        # vim /etc/ssh/sshd_config                         #键盘上按Shift+g 跳转到最后一行 在最后一行上添加

        .. ..

        DenyUsers *@*.my133t.org                        # 这个域名考试时会进行改变   

        #会也能够经过考试提供的注意事项  找道此域名对应网段   例如 my133t.org 对应的网段为 172.34.0.0

        DenyUsers   *@*172.34.0.*

        # systemctl restart sshd                                #重启ssh服务

        另外这道题也能够经过配置防火墙策略 将这个网段放入block区域

        具体操做请访问 http://www.javashuo.com/article/p-mhgxuvem-m.html

相关文章
相关标签/搜索