zoukankan      html  css  js  c++  java
  • linux配置ssh某用户只允许证书登陆

    1,客户端

    生成公钥与私钥

    ssh-keygen -t rsa -C ‘email’ -f ~/.ssh/user_ssh
    

    然后会在~/.ssh生成user_ssh, user_ssh.pub

    2,服务端

    user登录服务端,并上传user_ssh.pub到服务端

    配置ssh

    touch ~/.ssh/authorized_keys 
    
    cat user_ssh.pub >> ~/.ssh/authorized_keys 

    sudo /etc/init.d/ssh start
     

    禁止root账户并禁止所有用户密码登录

    # Subsystem sftp /usr/lib/openssh/sftp-server  #关闭sftp
    
    # Set this to 'yes' to enable PAM authentication, account processing,
    # and session processing. If this is enabled, PAM authentication will
    # be allowed through the ChallengeResponseAuthentication and
    # PAM authentication via ChallengeResponseAuthentication may bypass
    # If you just want the PAM account and session checks to run without
    # and ChallengeResponseAuthentication to 'no'.
    UsePAM yes
    UseDNS no
    AddressFamily inet
    PermitRootLogin no  #禁止root
    SyslogFacility AUTHPRIV
    PasswordAuthentication no #禁止密码方式验证
    

    3, 客户端测试  

    使用xshell, 指定服务器信息之后,在验证设置中选择使用验证方法为public key

    输入用户名, 选择我们在客户端生成的密钥, 如果生成公钥与私钥时候有输入通行密码即passphrase这里也要输入

    然后就以”免密码“ 方式可以登录了。

    我们再使用用户名密码ssh user@host这种方法登录则会如下图提示。

      

    :D

    以上个人简单笔记

  • 相关阅读:
    JavaIO流(四) File文件对象
    Java IO流(三) 字符流Reader和Writer
    Java IO流(二) 字节流InputStream和OutputStream
    Java IO流(一)入门
    Decorator(装饰者)模式
    Listener(监听器)
    Filter(过滤器)
    Java开发入门
    啊哈哈,写博客的第一天
    MySQL变量
  • 原文地址:https://www.cnblogs.com/shiv/p/5228102.html
Copyright © 2011-2022 走看看