Linux(CentOS)SFTPでの構成(書き込みに失敗しました:壊れたパイプがパケットを読み取れませんでした:ピアによって接続がリセットされました)..。



Configuration Linux Sftp Attached Resolve Write Failed



#sftpグループを作成します。

> Write failed: Broken pipe > Couldn't read packet: Connection reset by peer

#ユーザーsftpuserを作成します。



groupadd sftp

#促す:

useradd -g sftp -s /bin/false sftpuser

#sftpuserユーザーのパスワードを設定します。確認のためにパスワードを2回入力するように求められます。



/etc/group file contains all groups The presence of / etc / shadow / etc / passwd system all user names

#次のsftpアップロードディレクトリを作成します。

passwd sftpuser

#ユーザーsftpuserが配置されているディレクトリを変更します。

mkdir /datas/www

#sshd_configを構成します。



usermod -d /datas/www sftpuser
vi /etc/ssh/sshd_config 
# Find the following line, and comment
#Subsystem sftp /usr/libexec/openssh/sftp-server
# Add the following lines (if problems arise later added, it is added to the final)
Subsystem sftp internal-sftp # This line specifies sftp service using the system comes internal- usesftp Match User sftpuser # This line is used to match the user ChrootDirectory / Datas / www # chroot with the user's root directory assigned to / datas / www, so users only / datas /Activities at www AllowTcpForwarding no ForceCommand internal-sftp # sftp command specified

# 保存して終了

#Chrootディレクトリのアクセス許可セット:

Why internal-sftp instead of the default sftp-server, because: This is sftp service in a process when the user ChrootDirectory will not request any document Better performance, not to sftp to open a process. 

#SFTPユーザーログインを書き込むことができた後にディレクトリを作成します。

chown -R root:root /datas/www chmod 755 /datas/www

#sshdサービスを再起動します。

mkdir /datas/www/sftpuser chown -R sftpuser:sftp /datas/www/sftpuser/ chmod 755 /datas/www/sftpuser/

#通常の着陸かどうかをテストします。

service sshd restart

#SElinuxを閉じる:

sftp -P 22122 root@xxxxx127.0.0.1 

# 保存して終了

#ここで、この関数を閉じたい理由について説明します。 https://www.zhihu.com/question/20559538

一般的な問題:

1、sshd sshd_configファイルを再起動するように変更されました。指定:ディレクティブ「UseDNS」はMatchブロック内では許可されていません

不明な理由による構文エラー。2つの相互変調を構成する必要がある位置が指定されていません。

修正する前に:

vi /etc/sysconfig/selinux # Find the following line SELINUX=enforcing #change into SELINUX=disabled

変更後(つまり、順序を変更):

Subsystem sftp internal-sftp UsePAM yes Match user sftpuser1 ForceCommand internal-sftp ChrootDirectory /data/wwwroot/user1/ UseDNS no AddressFamily inet PermitRootLogin yes SyslogFacility AUTHPRIV PasswordAuthentication yes

参照: http://www.cnblogs.com/xjnotxj/p/6912471.html

2、次のプロンプトをリンクするときにサーバーの場合:

UseDNS no AddressFamily inet PermitRootLogin yes SyslogFacility AUTHPRIV PasswordAuthentication yes Subsystem sftp internal-sftp UsePAM yes Match user sftpuser1 ForceCommand internal-sftp ChrootDirectory /data/wwwroot/user1/

これは、ChrootDirectoryのアクセス許可に問題があるためです。すべてのユーザーのルートディレクトリを設定する必要があります。そうしないと、問題が発生します。したがって、すべてのsftpユーザーrootがrootであり、権限が750または755であることを確認してください。次の2つの原則に注意してください。

  • ディレクトリのディレクトリ所有者は、ルートシステムの先頭がrootになることしかできず、ユーザーグループがrootになることはできません。

  • ディレクトリが起動していて、ルートシステムがグループへの書き込みアクセス権を持っていない可能性があります

  • 特定の音符の2ポイント上で、再確認します。私はこの問題のために、この問題の原因がありました。問題を解決するために構成された慎重な調査の後。

参照:

https://segmentfault.com/a/1190000008578734

http://www.cnblogs.com/kgdxpr/p/3623369.html

http://blog.csdn.net/xinxin19881112/article/details/46831311