質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Q&A

解決済

1回答

3464閲覧

CentOS7サーバーにSFTP接続出来なくなった

退会済みユーザー

退会済みユーザー

総合スコア0

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

0グッド

1クリップ

投稿2017/10/24 09:20

編集2017/10/26 00:55

お世話になっております、よろしくお付き合いください。

目的

インターネット上に解説するサーバーを想定して、VMwareゲストOSとしてCentos7サーバーを構築しています。
webサーバーなので、/var/www/html/以下をメンテするユーザー(仮にwebグループのwebuser)はSSH接続(SFTPやSCPなど)させつつも、
古いシステムのためのデータ連携(CSVファイル送受信)のユーザー(仮にwebグループのnonsshuser)はFTPで接続できるようにしようとしています。

質問主旨

CentOS - CentOS7&Vsftpdで非SSHユーザーをFTPできるようにしたい(96994)|teratail
の件で、非SSHユーザーを設定してFTPできるようになったのですが、
逆にこれまでSFTP出来ていたユーザーが認証で通らなくなり困っています。
[preauth]って言葉に振り回されている感じで、穴を開ける前にはつながっていたWinSCPの設定にも困ってます。
かといってSSH全廃するわけにもいかないので、どうにか両立させたいです。
情報不足な点などありましたらご指摘ください。

環境、設定

サーバー側(VMwareのゲストOS、192.168.0.142)

/etc/pam.d/sshd

account required pam_access.so accessfile=/etc/security/sshd_access.conf

を追加。

/etc/security/sshd_access.conf

+ : webuser : ALL + : user : ALL

を追加。(webuserは /var/www/html/ 編集用ユーザー、user(仮)はシェル利用。)

/etc/ssh/sshd_configには

(略) # Authentication: #LoginGraceTime 2m #PermitRootLogin yes PermitRootLogin no #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 #RSAAuthentication yes #PubkeyAuthentication yes PubkeyAuthentication no (略) # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no PermitEmptyPasswords no #PasswordAuthentication yes PasswordAuthentication no (略) #KerberosAuthentication no (略) #GSSAPIAuthentication no (略) UsePAM yes (略) Match User nonsshuser PasswordAuthentication yes

nonsshuser(仮)はSSHを使わず、/var/www/html/more/deep/path(仮)をルートディレクトリとしてアクセスできるユーザー。

肝心のvar/log/secure

Oct 24 17:38:12 localhost sshd[27360]: Connection from 192.168.0.13 port 57968 on 192.168.0.142 port 22 Oct 24 17:38:12 localhost sshd[27360]: debug1: Client protocol version 2.0; client software version WinSCP_release_5.11.2 Oct 24 17:38:12 localhost sshd[27360]: debug1: no match: WinSCP_release_5.11.2 Oct 24 17:38:12 localhost sshd[27360]: debug1: Enabling compatibility mode for protocol 2.0 Oct 24 17:38:12 localhost sshd[27360]: debug1: Local version string SSH-2.0-OpenSSH_6.6.1 Oct 24 17:38:12 localhost sshd[27360]: debug1: SELinux support enabled [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: permanently_set_uid: 74/74 [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: list_hostkey_types: ssh-rsa,ecdsa -sha2-nistp256,ssh-ed25519 [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: SSH2_MSG_KEXINIT sent [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: SSH2_MSG_KEXINIT received [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: kex: client->server aes256-ctr hmac-sha2-256 none [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: kex: server->client aes256-ctr hmac-sha2-256 none [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32 [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32 [preauth] Oct 24 17:38:12 localhost sshd[27360]: debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: SSH2_MSG_NEWKEYS sent [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: expecting SSH2_MSG_NEWKEYS [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: SSH2_MSG_NEWKEYS received [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: KEX done [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: userauth-request for user webuser service ssh-connection method none [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: attempt 0 failures 0 [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: PAM: initializing for "webuser" Oct 24 17:38:13 localhost sshd[27360]: debug1: PAM: setting PAM_RHOST to "192.16 8.0.13" Oct 24 17:38:13 localhost sshd[27360]: debug1: PAM: setting PAM_TTY to "ssh" Oct 24 17:38:13 localhost sshd[27360]: error: Received disconnect from 192.168.0.13: 14: No supported authentication methods available [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: do_cleanup [preauth] Oct 24 17:38:13 localhost sshd[27360]: debug1: monitor_read_log: child log fd cl osed Oct 24 17:38:13 localhost sshd[27360]: debug1: do_cleanup Oct 24 17:38:13 localhost sshd[27360]: debug1: PAM: cleanup Oct 24 17:38:13 localhost sshd[27360]: debug1: Killing privsep child 27361

ユーザー側(WindowsホストOS、WinSCPでSFTPしようとしている)

ログファイルはこんな感じ。

. 2017-10-24 17:38:11.791 Looking up host "192.168.0.142" for SSH connection . 2017-10-24 17:38:11.791 Connecting to 192.168.0.142 port 22 . 2017-10-24 17:38:11.791 We claim version: SSH-2.0-WinSCP_release_5.11.2 . 2017-10-24 17:38:11.804 Server version: SSH-2.0-OpenSSH_6.6.1 . 2017-10-24 17:38:11.804 We believe remote version has SSH-2 channel request bug . 2017-10-24 17:38:11.804 Using SSH protocol version 2 . 2017-10-24 17:38:11.804 Have a known host key of type ssh-ed25519 . 2017-10-24 17:38:11.804 Doing ECDH key exchange with curve Curve25519 and hash SHA-256 . 2017-10-24 17:38:12.219 Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them . 2017-10-24 17:38:12.220 Host key fingerprint is: . 2017-10-24 17:38:12.220 ssh-ed25519 256 1e:d3:9c:79:8f:9c:e2:f9:03:a9:69:49:e1:01:ca:35 . 2017-10-24 17:38:12.220 Verifying host key ssh-ed25519 0x45f4700d62fad8c2 7f2498cbde78352d d913e573f206fd7a 4990bbfcc834b450 ,0x25dbc0e879f9240e e2c2e71c7d7904b3 89c7d64853411a2b 4dc5b92802963bae with fingerprint ssh-ed25519 256 1e:d3:9c:79:8f:9c:e2:f9:03:a9:69:49:e1:01:ca:35 . 2017-10-24 17:38:12.258 Host key matches cached key . 2017-10-24 17:38:12.258 Initialised AES-256 SDCTR client->server encryption . 2017-10-24 17:38:12.258 Initialised HMAC-SHA-256 client->server MAC algorithm . 2017-10-24 17:38:12.258 Initialised AES-256 SDCTR server->client encryption . 2017-10-24 17:38:12.258 Initialised HMAC-SHA-256 server->client MAC algorithm . 2017-10-24 17:38:12.299 Reading key file "C:\~~~~~~\webuser_private_key.ppk" ! 2017-10-24 17:38:12.300 Using username "webuser". . 2017-10-24 17:38:12.323 Server offered these authentication methods: . 2017-10-24 17:38:12.323 Disconnected: No supported authentication methods available (server sent: ) * 2017-10-24 17:38:12.336 (EFatal) Disconnected: No supported authentication methods available (server sent: ) * 2017-10-24 17:38:12.336 認証ログ (詳細はセッション ログを見て下さい): * 2017-10-24 17:38:12.336 ユーザ名"webuser" を使用中 * 2017-10-24 17:38:12.336 * 2017-10-24 17:38:12.336 認証に失敗

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

TaichiYanagiya

2017/10/25 15:36

やりたいことは、「webuser はパスワード認証で SFTP させたい。nonsshuser は FTP/FTPS させたいが、SSH/SFTP/SCP させない。」ということですか?
退会済みユーザー

退会済みユーザー

2017/10/26 00:49

わかりにくくてすみません、そういうことです。nonsshuserは古いシステムのための非常手段として、SSHを使わずに利用できるようにしたいのです。
guest

回答1

0

ベストアンサー

sshd_config で PasswordAuthentication no と設定したため、パスワード認証ができなくなっています。

###パスワード認証の許可
sshd_config で PasswordAuthentication yes に戻します。
また、Match User nonsshuser 箇所も無意味ですので、削除します。

###nonsshuser の SSH 禁止
pam_access で制限してもいいですが、sshd_config で DenyUsers nonsshuser と設定した方が簡単です。

投稿2017/10/26 03:27

TaichiYanagiya

総合スコア12146

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2017/10/26 03:39

回答有り難うございます。まだ試す前ですが、その方向ならパスワード認証できそうですね。 SSH使いたい→SSH 鍵認証したい(よりセキュアだし)という考えでおりました。パスワード認証ができるのはnonsshuserだけで、他のユーザーは鍵認証でいいかなって。パスワード認証だけでもいいのかなぁ、インターネット上にホストするサーバーは。鍵認証にこだわらないほうが良いでしょうか。
TaichiYanagiya

2017/10/26 03:50

鍵認証にできるのであれば、鍵認証のみにした方がいいです。 "PubkeyAuthentication yes", "PasswordAuthentication no" とする必要があります。 なぜ、"PubkeyAuthentication no" としたのかわかりませんが。
退会済みユーザー

退会済みユーザー

2017/10/26 04:03

あっ、"PubkeyAuthentication no"をyesにしただけで直ったようです。WinSCPもttsshもつながるようになりました。なぜnoにしていたのかは今となってはよくわかりません。お恥ずかしい。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問