VTRyo Blog

一歩ずつ前に進むブログ

vagrantがGithubと通信できない

f:id:vtryo:20180716020602p:plain

ども。今回はgithubと通信できない問題が発生したので、その解消方法を書いておきます。

サムネイルがVulsな理由は後ほど・・・!

さて、ことの始まりは開発チームからの依頼でした。

vagrantでcomposerインストールができない

今までできていたcomposerがインストールできないので確認依頼が来ました。

[vagrant@localhost vagrant]$ php ./composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 1 install, 0 updates, 0 removals
    Failed to download aws/aws-sdk-php from dist: The zip extension and unzip command are both missing, skipping.
The php.ini used by your command-line PHP is: /etc/php.ini
    Now trying to download from source
  - Installing aws/aws-sdk-php (3.52.8): Cloning fbbbf393a8

  [RuntimeException]
  Failed to clone https://github.com/aws/aws-sdk-php.git via https, ssh protocols, aborting.
  - https://github.com/aws/aws-sdk-php.git
    error:  while accessing https://github.com/aws/aws-sdk-php.git/info/refs

    fatal: HTTP request failed
  - git@github.com:aws/aws-sdk-php.git
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly

エラーを見る限り、すぐに何か判定出来ないので上から見てみました。

Failed to download aws/aws-sdk-php from dist: The zip extension and unzip command are both missing, skipping.

zipがないということでやってみます。
ありませんね。

[vagrant@localhost ]$ zip
-bash: zip: コマンドが見つかりません
[vagrant@localhost ]$ unzip
-bash: unzip: コマンドが見つかりません

しかし今まで問題なくできていたということは、zipの有無が問題ではないと判断しました。

よくよく見ると、git cloneに失敗しているのがわかります。 composerインストールではなく、git cloneしてみます。

[vagrant@localhost tmp]$ git clone https://github.com/aws/aws-sdk-php.git
Initialized empty Git repository in /var/tmp/aws-sdk-php/.git/
error:  while accessing https://github.com/aws/aws-sdk-php.git/info/refs

fatal: HTTP request failed

どうやらgithubとの通信がイケてないと判明します。

ためしにhttps://github.com/aws/aws-sdk-php.git/info/refsにアクセスすると、以下のようなメッセージがでました。

Please upgrade your git client.
GitHub.com no longer supports git over dumb-http: https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days

どうやらgit clientが古いとのこと。
実際にgitのバージョンを調べると、かなり古いものでした。

[vagrant@localhost tmp]$ git version
git version 1.7.1

というわけでgitをバージョンアップしてみました。

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
cd /etc/yum.repos.d/
wget http://wing-repo.net/wing/6/EL6.wing.repo
yum --enablerepo=wing install git
[vagrant@localhost tmp]$ git version
git version 2.16.2

バージョンがあがったところで再実行。

[vagrant@localhost tmp]$ sudo git clone https://github.com/aws/aws-sdk-php.git
Cloning into 'aws-sdk-php'...
fatal: unable to access 'https://github.com/aws/aws-sdk-php.git/': SSL connect error

エラー内容が変わりましたね。

そしてこのエラー内容でググると、すぐに原因にたどり着きました。

SSLエラーはcurlが古いと発生するらしいです。

解決策に従ってアップデートします。

yum update -y nss curl libcurl

そしてgit clone

[vagrant@localhost tmp]$ sudo git clone https://github.com/aws/aws-sdk-php.git
remote: Counting objects: 49385, done.
remote: Compressing objects: 100% (210/210), done.
remote: Total 49385 (delta 120), reused 112 (delta 40), pack-reused 49122
Receiving objects: 100% (49385/49385), 39.48 MiB | 2.31 MiB/s, done.
Resolving deltas: 100% (30969/30969), done.
Checking out files: 100% (2290/2290), done.

イケた!

このあと、開発チームの方にcomposerを再インストールしてもらいました。
ただし、ものは試しでgitのバージョンは変更せずにやってもらった所、問題なくできたのでcurlが問題だったことがわかりました。

libcurlの脆弱性

ここから話はがらっと変わり、なぜcurlが古いとGithubと通信できなかったかということ。

Githubからのニュースで、実は事前にお知らせがあったようです。

https://githubengineering.com/crypto-removal-notice/

https://githubengineering.com/crypto-deprecation-notice/

どうやら「脆弱性のある通信方法を回避するためにこれまでの通信方法を無効化するよ」ということらしいです。

もっと詳しく言うと、「TLS 1/TLS 1.1を使用した通信はしないよ」ということでしょう。
そのため、今回libcurlやnssをアップデートする必要があったと見ます。

vulsで検知が一番かも

そういえば、libcurlの脆弱性がありましたね。 もちろん、Vulsユーザの方はご存知ですよね?

今回はvagrantというローカル環境だったこともあり、めったにアップデートしないため発生したのかなと思います。

業務用サーバ等は、Vulsでしっかり検知して対応していきましょう!

参考

突然GitHubとhttps通信できなくなったときの解決メモ