zoukankan      html  css  js  c++  java
  • Linux下只允许用户远程scp

    本文将介绍在Linux环境下,让用户不能远程登录 只能使用scp命令

    使用到的软件:rssh(http://pizzashack.org/rssh/index.shtml )

    环境:centos6.x

    配置好epel源

    curl firxiao.com/sh/chrepo.sh|sh
    

    将自动配置base 及epel源为阿里云的源。

    安装rssh

    yum install -y rssh
    

    安装完会多一个二进制的rssh

    ls -l /usr/bin/rssh
    -rwxr-x---. 1 root rsshusers 25816 10月  1 02:10 /usr/bin/rssh
    

    配置用户

    添加一个test用户并给给予一个密码。 注意用户组及赋予给它的默认shell

    useradd test -g rsshusers -s /usr/bin/rssh
    echo "test"|passwd --stdin test
    

    对于已经存在的用户可以将其用户组改为rsshusers ,默认shell改为 /usr/bin/rssh 即可

    如下命令

    usermod -G rsshusers -s /usr/bin/rssh  user_exists
    

    配置rssh

    rssh配置文件位于/etc/rssh.conf

    在配置文件最后添加

    allowscp
    

    验证

    第一步 ssh验证

    ssh test@localhost 进行验证

    #ssh test@localhost
    This account is restricted by rssh.
    Allowed commands: scp
    If you believe this is in error, please contact your system administrator.
    Connection to localhost closed.
    

    第二步 scp验证

    scp install.log test@localhost:/home/test
    test@localhost's password:
    install.log                                  100% 9169     9.0KB/s   00:00
    

    至此配置完成

  • 相关阅读:
    YOLOv5目标检测源码重磅发布了!
    CSS文本
    CSS3:透明度
    CSS3:HSL和HSLA
    颜色-背景色
    颜色-前景色
    列表 图像 链接
    CSS简介
    标记和插入音频视频
    表单
  • 原文地址:https://www.cnblogs.com/oskb/p/8386625.html
Copyright © 2011-2022 走看看