zoukankan      html  css  js  c++  java
  • 服务器ssh安全配置

    服务器ssh安全配置

    新增用户

    -m创建用户目录

    useradd -m wilwei

    设置修改密码

    passwd wilwei

    为用户指定shell

    usermod -s /bin/bash wilwei

    为用户指定登录默认目录

    usermod -d /app wilwei

    bashrc失效问题,手动创建用户后复制/etc/skel到/home/newuser生效
    使用useradd -m无此问题

    安装fail2ban

    sudo apt-get install fail2ban

    更改ssh默认端口号

    vim /etc/ssh/sshd_config

    port ?

    密钥登录

    本地生成公钥

    -t 指定加密算法; -b 指定生成的密钥长度; -C 一句话,一般都填邮箱地址。
    
    ssh-keygen -t rsa -b 4096 -C "你的邮箱地址"
    

    本地复制公钥要服务器(默认使用 ~/.ssh/id_rsa.pub 这个文件中的内容,复制到目标服务器的 ~/.ssh/authorized_keys 文件内)

    #-p 指定端口号
    ssh-copy-id -p <portNumber> username@remote-hostname
    #指定位置
    ssh-copy-id -i ~/.ssh/id_ed25519 username@remote-hostname
    

    修改服务器ssh配置

    vim /etc/ssh/sshd_config
    
    #禁止密码登录
    #PasswordAuthentication no
    #禁止root登录
    #PermitRootLogin no
    
    #重启
    service sshd restart
    
  • 相关阅读:
    Load样式——1
    通过mybatis-generator-core-1.3.2.jar逆向工程生成
    阶乘
    八进制
    xshell跳转设置 Xshell代理设置
    spark
    内存模型学习-- Container Executor task之间的关系
    scala 学习笔记--闭了个包
    scala 学习笔记--模式匹配
    scala 学习笔记--集合
  • 原文地址:https://www.cnblogs.com/wilwei/p/15074547.html
Copyright © 2011-2022 走看看