Linux下只允許使用者遠端scp

2022-05-22 05:42:10 字數 1185 閱讀 9277

本文將介紹在linux環境下,讓使用者不能遠端登入 只能使用scp命令

使用到的軟體:rssh( )

環境:centos6.x

將自動配置base 及epel源為阿里雲的源。

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配置檔案位於/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

至此配置完成

Linux建立使用者,SFTP只允許訪問指定目錄

首先建立使用者 useradd lus1 passwd lus1 我這裡配置lus1這個使用者目錄,為sftp指向目錄,即 home lus1 vim etc ssh sshd config 這個記得要在原有的配置檔案注釋掉 subsystem sftp usr libexec openssh sf...

只允許指定使用者登入SSH

為安全需要,可以指定某使用者才能登入ssh 軟體環境 ssh v openssh 5.3p1,openssl 1.0.0 fips 29 mar 2010 1 在 etc ssh sshd config檔案中新增如下語句 允許admin可以在任何地方登入 allowusers admin 或設定成其...

ubuntu下允許root使用者ssh遠端登入

ssh伺服器,可以通過ssh協議來訪問遠端伺服器,代替telnet和ftp。但是ubuntu預設是不啟用root使用者也不允許root遠端登入的。所以需要先啟用root使用者 啟用root使用者 sudo passwd root 修改密碼後就啟用了。安裝openssh server 1.使用apt命...