Linux下只允許用戶遠程scp

jopen 9年前發布 | 16K 次閱讀 Linux

本文將介紹在Linux環境下,讓用戶不能遠程登錄 只能使用scp命令 

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

環境:centos6.x

配置好eple源

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



至此配置完成

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!