#navi(../)
* SFTPを有効・無効化する方法 [#ua25304c]
SFTPを有効、無効にする方法(設定)を以下に記します。

#contents
#htmlinsertpcsp(linux_ads_top.html,linux-sp.html)

* SFTPについて [#j09730b3]
SFTPとはSSHのサブシステムとして動作します。~
したがって、sshdが動いていないとSFTPも利用することができないので注意してください。

ちなみにクライアントとしてsftpコマンドがあります。~
以下のコマンドでログインすることができます。
 sftp [ユーザアカウント@]接続先サーバ
クライアントコマンドであるsftpの操作コマンドについては、man sftpをすれば調べることができます。~

* SFTPの有効・無効手順と実行例 [#bc0c9a09]
上述した通り、SSHのサブシステムとして動作しているので、SSHの設定ファイルを編集することにより、有効・無効にすることができます。~
以下、CentOSでSFTPの有効・無効のテストを行いました。

** 設定ファイル /etc/ssh/sshd_config [#gf35874f]
SSHの設定ファイルであるsshd_configを編集します。~
管理者権限(rootなど)で編集してください。~
尚、ssh_configというファイルもあります。~
編集するファイルはssh''d''_configです。

- 編集前(SFTP動作中) - /etc/ssh/sshd_config
Subsystemにsftpがされているのがわかります。
 <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...が表示されています。

- 編集後(SFTP停止) - /etc/ssh/sshd_config
以下の手順を管理者権限(rootなど)でSFTPを無効化しました。~
+ Subsystemの前に#を追記しコメントアウトしました。
 # override default of no subsystems
 #Subsystem       sftp    /usr/libexec/openssh/sftp-server
+ sshdの再起動
 # /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の有効、無効化方法でした。

* 関連資料 [#kc845ca3]
-[[Ubuntu DesktopにSSHサーバーをインストールする方法>Ubuntu DesktopにSSHサーバーをインストールする方法]]

#htmlinsertpcsp(linux_ads_btm.html,linux-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS