20
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sftpのみ許可

Last updated at Posted at 2014-06-30

設定

adduser --home / --no-create-home --shell /bin/false sftp-only
/home/sftp-only/.ssh/authorized_keys
+ command="internal-sftp" ssh-rsa ...

/etc/ssh/sshd_config

Subsystem sftp internal-sftp -f authpriv -l info

Match User sftp-only
  ChrootDirectory /chroot
  AllowTcpForwarding no
  PermitTunnel no
  X11Forwarding no
syntax check
sshd -t
  • 何も出力されなければ正常。
sshd再起動
/etc/init.d/ssh restart

ディレクトリ生成時、 現在のディレクトリのgidを引き継ぐ方法

chmod g+s dirname

ロギング(未確認)

/home/sftp-only/.ssh/authorized_keys
+ command="internal-sftp -f LOCAL6 -l INFO" ssh-rsa ...
/etc/rsyslog.d/50-sftp.conf
local6.*  /var/log/sftp.log
/etc/init.d/rsyslog restart

rsshを使う

  • 接続方式をsftpやscp等に限りたいという場合役立つ
/etc/passwd
sftp-only:x:1000:1000:,,,:/home/sftp-only:/usr/bin/rssh
/etc/shells
+ /usr/bin/rssh
/etc/rssh.conf
+ user=sftp-only:022:000100:

user=~の部分は前から
ユーザー名
umask値
access bit(rsync,rdist,cvs,sftp,scpの順。1で許可、0で不許可)
chrootされるパス

  • /usr/share/doc/rssh/examples/mkchroot.sh
20
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?