sftp専用ユーザ

SFTPユーザ一覧

IDpasswordサーバuid
sftp-oistuploadm7683001
sftp-fujiwaraWk2sdz6Ym7683002
sftp-takadakitasatom7683003
sftp-futahashiV7vwSjNLm7683004

SSH可能ユーザ一覧

IDpasswordサーバuid
kitasato2e2KF9X5m7684001

SFTP専用ユーザの作成

/etc/ssh/sshd_configを編集する。

Match User sftp-fujiwara
  ChrootDirectory /data2/sftp-fujiwara
  ForceCommand internal-sftp
  PasswordAuthentication yes
useradd -u $uid sftp-fujiwara
passwd sftp-fujiwara

ChrootDirectory先のディレクトリは親も含めてroot所有にしておく。そうしないと

fatal: bad ownership or modes for chroot directory component “/data2/” [postauth]

というエラーが出る。

mkdir /data2/sftp-fujiwara
chown root:root /data2/sftp-fujiwara
chmod 755 /data2/sftp-fujiwara

upload用ディレクトリの作成

mkdir /data2/sftp-fujiwara/upload
chmod 777 /data2/sftp-fujiwara/upload

systemctl restart sshd

確認

sftp sftp-fujiwara@localhost
cd upload
put 適当なファイル
  • sftp専用ユーザ.1548070110.txt.gz
  • 最終更新: 2019/01/21 11:28
  • by suikou