SFTPを有効、無効にする方法(設定)を以下に記します。
SFTPとはSSHのサブシステムとして動作します。
したがって、sshdが動いていないとSFTPも利用することができないので注意してください。
ちなみにクライアントとしてsftpコマンドがあります。
以下のコマンドでログインすることができます。
sftp [ユーザアカウント@]接続先サーバ
クライアントコマンドであるsftpの操作コマンドについては、man sftpをすれば調べることができます。
上述した通り、SSHのサブシステムとして動作しているので、SSHの設定ファイルを編集することにより、有効・無効にすることができます。
以下、CentOSでSFTPの有効・無効のテストを行いました。
SSHの設定ファイルであるsshd_configを編集します。
管理者権限(rootなど)で編集してください。
尚、ssh_configというファイルもあります。
編集するファイルはsshd_configです。
<snip> # override default of no subsystems Subsystem sftp /usr/libexec/openssh/sftp-server一般ユーザ(sakura)からsftpコマンドで接続してみます。
$ sftp sakura@localhost Connecting to localhost... The authenticity of host 'localhost (127.0.0.1)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (RSA) to the list of known hosts. sakura@localhost's password: sftp> bye初めてのsshによる接続だったのでThe authenticity of host...が表示されています。
# override default of no subsystems #Subsystem sftp /usr/libexec/openssh/sftp-server
# /etc/init.d/sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ]一般ユーザ(sakura)からsftpコマンドで接続してみます。
$ sftp sakura@localhost Connecting to localhost... sakura@localhost's password: Request for subsystem 'sftp' failed on channel 0 Couldn't read packet: Connection reset by peer接続できなくなりました。(SFTPの無効化)
以上、SFTPの有効、無効化方法でした。