ssh的具体用法及linux系统服务的管理

1.配置网络ip

执行命令 [[email protected] Desktop]# nm-connection-editor

ssh的具体用法及linux系统服务的管理

ssh的具体用法及linux系统服务的管理

ssh的具体用法及linux系统服务的管理

ssh的具体用法及linux系统服务的管理

根据以上步骤配置好客户端和服务端的ip

2.在客户端利用ssh连接服务端

[[email protected] Desktop]# ssh   [email protected]

ssh的具体用法及linux系统服务的管理

确认并输入服务端**后就成功连接到服务端

[[email protected] Desktop]#  exit                       ##退出服务端

注:以上连接方式是不能打开远程主机的图形功能的如果需要打开远程主机图形功能需要输入 -X
[[email protected] Desktop]# ssh -X [email protected]                          

[[email protected] ~]# cheese

3.给ssh服务添加key认证

[[email protected] Desktop]# ssh-******

ssh的具体用法及linux系统服务的管理

[[email protected] Desktop]# ssh-copy-id -i /root/.ssh/id_rsa.pub  [email protected]          ##创建并查看key

ssh的具体用法及linux系统服务的管理

[[email protected] Desktop]# scp  /root/.ssh/id_rsa  [email protected]:/root/.ssh/                 ##169为客户端

ssh-copy-id                            ##加密命令
-i                                           ##指定**
/root/.ssh/id_rsa.pub               ##**
root                                       ##加密用户
172.25.254.200                      ##主机ip

ssh的具体用法及linux系统服务的管理

ssh的具体用法及linux系统服务的管理

再次用ssh连接时就无需输入**

[[email protected] Desktop]# rm -fr /root/.ssh/authorized_keys                            ##当此文件被删除,客户端解密文件失效

ssh的具体用法及linux系统服务的管理

[[email protected] Desktop]# cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys   ##从新生成锁文件,解密文件功能恢复

ssh的具体用法及linux系统服务的管理

4.sshd的安全配置以及系统服务的管理

  • 禁止原始认证方式
78 PasswordAuthentication no|yes     ##开启或关闭ssh的默认认证方式
48 PermitRootLogin no|yes               ##开启或关闭root用户的登陆权限
79 AllowUsers westos                      ##用户白名单,当前设定是只允许westos登陆

80 DenyUsers linux                          ##用户黑名单,当前设定是只不允许linux登陆

ssh的具体用法及linux系统服务的管理ssh的具体用法及linux系统服务的管理##利用vim将光标所在行最后的yes改为no

ssh的具体用法及linux系统服务的管理        ##先删除key认证,此时用ssh连接则会失败

  • linux系统中服务的管理
systemctl       动作       服务
systemctl       start        sshd        #开启服务
systemctl       stop        sshd        #停止服务
systemctl       status      sshd        #查看服务状态
systemctl       restart     sshd        #重启服务
systemctl       reload     sshd        #让服务从新加载配置
systemctl       enable     sshd        #设定服务开启启动
systemctl       disable    sshd        #设定服务开机不启动

systemctl list-unit-files                #查看系统中所有服务的开机启动状态
systemctl list-units                      #查看系统中所有开启的服务
systemctl set-default graphical.target    #开机时开启图形
systemctl set-default multi-user.targe    #开机时不开图形