openssh远程连接及tcpwrappers防护

ssh

ssh是一种安全通道协议,主要用于字符界面的远程,提高了安全性
openssh实现ssh协议的开源项目

Openssh的配置

openssh服务器由openssh-clients,openssh_server 等软件包提供(默认安装),属于C/S结构(一个提供服务,一个使用)B/S结构(线上作业)

  • 服务名称:sshd
  • 服务端主程序:/usr/sbin/sshd
  • 服务端配置文件:/etc/ssh/sshd_config daemon(守护进程)
  • 客户端配置文件:/etc/ssh/ssh_config

1.服务端监听选项

  vim /etc/ssh/sshd_config
  17 Port 22      #监听端口
  19 ListenAddress 0.0.0.0        #监听IP地址,默认0.0.0.0
  20 Protocol 2        #ssh协议的版本V2比V1更好
  116 UseDNS no        #禁用DNS方向解可以提高速度 
 
  systemctl restart sshd  #重新识别
  netstat -lnpt | grep ssh   #查看ssh端口

2.用户登录控制

sshd服务默认root用户登录,由于具有风险,一般都是通过普通用户进入shell安全环境,在su root

vim etc/ssh/sshd_config
38 LoginCrceTime 10s     #登录验证时间10s
39 PermitRootLogin no      #禁止root用户登录
41 MaxAuthTrles 3      #主打重试次数3
65 PermitEmpyPasswords no      #禁止空密码用户登录

systemctl restart sshd      #重新识别

useradd test      #创建用户
passwd -d test      #设置用户秘密为空

  ##客户端连接测试##

OPenssh服务访问控制
* AllowUsers 仅允许用户登录
* DenyUsers 仅禁止用户登录

  1. 登录验证方式
  • 密码验证
  • 密钥对验证
    要求提供相匹配的密钥信息。通常先在客户端创建一对密钥(公钥/私钥),公钥放在服务器的指定文件。
vim /etc/ssh/sshd_config
66 PasswordAuthenticatlon yes    #启用密码
44 PubkeyAuthentication  yes    #启动密钥对
48 AuthorizedkeysFile _ssh/sutorize_keys  #指定公钥文件
原文地址:https://www.cnblogs.com/wml3030/p/15217721.html