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に指定したディレクトリになってしまうので悩みどころ