LoginSignup
69
67

More than 5 years have passed since last update.

ネット回線を変えたら、サーバーにssh出来ず、ssh_exchange_identification: read: Connection reset by peer になった時の対応

Posted at

前置き

チョット前に自宅のネット回線をADSLに戻しました。
そしたら、さくらVPSにsshできなくなってしまいました。
その時の対応です。

状況

  • PC: MacBookPro (Mavericks)
  • サーバー: さくらVPS(CentOS 6.5)
  • ssh出来ていた時の回線: WiMAX(レンタル)
  • 現在の回線: ADSL

エラーメッセージ

Macからサーバーにssh仕様としたらこんなメッセージが出ました。

watashi% ssh sakuradev
ssh_exchange_identification: read: Connection reset by peer

Connection reset?

とりあえずサーバー側のせいで繋がらなくなっちゃったかなって思いました。

詳細をみます。

watashi% ssh -v sakuradev
OpenSSH_hoge, OSSLShim hogehoge dd mm yyyy
debug1: Reading configuration data /Users/hoge/.ssh/config
debug1: /Users/hoge/.ssh/config line 7: Applying options for sakuradev
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port xxxxx.
debug1: Connection established.
debug1: identity file /Users/watashi/.ssh/kagi type -1
debug1: identity file /Users/watashi/.ssh/kagi-cert type -1
debug1: Enabling compatibility mode for protocol hoge
debug1: Local version string SSH-hogehoge-OpenSSH_hogehogehogehoge
ssh_exchange_identification: read: Connection reset by peer

やっぱり、ローカル側でなくサーバー側の問題かな。

wifiを変更

これまで入っていたwifiに繋ぎ直して、サーバーに入ります。
私の場合は、softbankのlte回線のテザリングを使いました。

/var/log/secure を見る

サーバーへの接続状況を見るために、サーバー側の/var/log/secureを見ます。

$ sudo cat /var/log/secure
----
mm dd 00:00:00 watashi sshd11111]: refused connect from softbankhogehogehogehoge.bbtec.net (xxx.xxx.xxx.xxx)

確かにsoftbankhogehogehogehoge.bbtec.netからのアクセスが拒否されています。

/etc/hosts.allow へIPを追加

以下の様にxxx.xxx.xxx.xxxからのアクセスを許可します。

server watashi$ sudo vim /etc/hosts.allow
----

ALL: 127.0.0.1, xxx.xxx.xxx.xxx
sshd: .jp

ちなみに /etc/hosts.denyはこんな感じ。

server watashi$ sudo vim /etc/hosts.deny
---

sshd: ALL

これでローカルからのsshが通るようになりました。

69
67
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
69
67