LoginSignup
0
1

More than 3 years have passed since last update.

sshd設定 scp sftpトラブルシューティング

Last updated at Posted at 2020-03-12

scp packet_write_wait: Connection to port 22: Broken pipe lost connection

多分、ディレクトリのパーミッションが怪しい

/etc/ssh/sshd_config

Match group sftp-testuser
  ChrootDirectory /hoge/fuge/data/testuser
  X11Forwarding no
  AllowTcpForwarding no
  PasswordAuthentication no
  PubkeyAuthentication yes
  ForceCommand internal-sftp

とした場合

ちなみに 
   PasswordAuthentication no
   PubkeyAuthentication yes
は鍵認証の場合の設定で
   ForceCommand internal-sftp
はsftpのみ ssh,scpは利用できません

パーミッション・ユーザは

ll /hoge/fuge/data
drwxr-xr-x. 3 root root 4096  3月 12 14:06 2020 testuser

ll /hoge/fuge/data/testuser/
drwxrwxrwx. 2 sftp-testuser sftp-testuser 4096  3月 12 16:03 2020 uploaddata

となるべき。
ChrootDirectoryで指定したディレクトリはrootでしか扱えないようにしなければならず
ChrootDirectory直下にはファイル・ディレクトリはsftpユーザは置けない

Directive 'AuthorizedKeysFile' is not allowed within a Match block

AuthorizedKeysFileディレクティブはsshd_configファイルの中では1つだけっぽい
自分はMatchブロックにAuthorizedKeysFileを書いていたのでNGを食らってた
まあ、メッセージそのままなんですけどね
ChrootDirectoryを使うとユーザ.sshディレクトリは使えないっぽいのでAuthorizedKeysFileで指定するが必要

ただ、AuthorizedKeysFileで.sshディレクトリを変更してしまうとssh通常ユーザの鍵管理ディレクトリもAuthorizedKeysFileに指定したディレクトリになってしまうので悩みどころ

0
1
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
0
1