公司需要對指定使用者進行限制,只允許訪問指定目錄,網上翻了一大堆一直有問題,經過最後研究,其實只是乙個小細節配置有問題;
具體流程如下:
1、建立使用者:useradd -d directory username
2、修改密碼:passwd username
3、配置sshd_config
subsystem sftp internal-sftp
match user shlver
chrootdirectory
directory
x11forwarding
noallowtcpforwarding no
forcecommand internal-sftp
4、重啟ssh服務:service sshd restart
5、修改目錄許可權:chown -r group:username directory
注:問題來了,一般大家出現問題在chrootdirectory directory上,這個地方的目錄不能直接配置到目標目錄,需要配置到他的上一級;
ssh使用者訪問特定目錄
配置ssh使用者只訪問特定目錄 1,新增使用者 新增使用者組 groupadd groupname新增使用者 useradd username m s bin bash d home username g groupname引數說明 s sbin nologin設定不能登陸 s bin false ...
centos 建立sftp使用者訪問特定目錄
建立sftp組 groupadd sftp 新增sftp方式登入使用者sftpuser,限制使用者無法ssh登入伺服器 useradd g sftp s bin false sftpuser echo 1234 passwd sftpuser stdin 建立sftpuser目錄data目錄,sft...
github配置ssh 訪問
linux進入.ss 件夾 cd ssh,新建config檔案 touch config 或者 touch ssh config。這裡要注意,沒有.ss 件夾的要新建乙個.ssh名的資料夾。steven ssh keygen t rsa f id rsa github steven ls id rs...