zoukankan      html  css  js  c++  java
  • Linux openSSH 只能够使用SFTP 不能使用ssh登陆实施目标

    一、需求
    1. 用户只能通过sftp访问,不能登录SSH
    2. 用户要被锁定在特定的目录下,没有读写其它目录的权限
    二、实施
    1.建立sftp用户

    下面建立sftp组和一个测试用户user,该用户属于sftp组:
    groupadd sftp
    useradd -d /home/user -m -s /bin/false -g sftp user #测试下来默认shell环境为/bin/bash也可以
    sudo passwd user

    2修改sshd的配置文件(/etc/ssh/sshd_config):
    1)注释改行
    #Subsystem sftp /usr/lib/openssh/sftp-server
    2)在文末添加如下
    Subsystem sftp internal-sftp
    Match group sftp
    #匹配sftp组,如为单个用户可用:Match user 用户名;  设置此用户登陆时的shell设为/bin/false,这样它就不能用ssh只能用sftp
    ChrootDirectory /data
    #指定用户被锁定到的那个目录,为了能够chroot成功,该目录必须属主是root,并且其他用户或组不能写
    X11Forwarding no
    AllowTcpForwarding no
    ForceCommand internal-sftp
    重启SSH服务 sshd:
    # /etc/init.d/ssh reload

    此时,使用带有sftp功能的客户端软件,比如filezilla、flashfxp就可以用testuser使用sftp方式登录服务器了;

  • 相关阅读:
    Softmax
    网络流模板大全
    简单数据结构题(from 钟子谦——IOI2018集训队自选题)
    [POJ3177]Redundant Paths
    [BZOJ1051][HAOI2006]受欢迎的牛
    [BZOJ2036]聪明的阿卑多
    [BZOJ1455]罗马游戏
    [POJ2942][LA3523]Knights of the Round Table
    [POJ3352]Road Construction
    练级(train)
  • 原文地址:https://www.cnblogs.com/dotagg/p/8432556.html
Copyright © 2011-2022 走看看