4
5

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.

chroot用に/etc/{passwd,group}作成

Last updated at Posted at 2014-10-18

sftp接続した時、ファイルの所有者が数字で表示される問題を解決する。

chroot環境のrootdirを /chroot/ に設定した場合、

  • /chroot/etc/passwd <-- uidの名前解決用
  • /chroot/etc/group <-- gidの名前解決用

この二つがあればよい。

sftponlyグループの名前解決だけであれば、以下コマンドでファイルを生成すれば良い。

生成手順

自分一人の場合はハードリンクでもいいでしょう。

sftponlyグループのGIDを確認しておく。
$ grep sftponly /etc/group
sftponly:x:1002

1002ということが分かった。

chroot環境用に生成
grep 1002 /etc/group > /chroot/etc/group
grep 1002 /etc/passwd > /chroot/etc/passwd

/chroot/etc/group と /chroot/etc/passwd はsftpでログインするユーザから読み込みができること。

あとはユーザを追加するたびに/chroot/etc/passwdを更新すればよい。

4
5
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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?