はじめに
時刻がずれているCentOSでコマンドを実行したらエラーが出たというお話です。
いつもならちゃんと時刻同期設定をするのに、急いでたりしたら忘れるかもしれません。
そんな方に少しでもお役に立てればと思い書いてみました。
※少し実行結果を切り貼りしたので、おかしい部分もあるかもしれませんがご容赦ください。
環境
Windows10にインストールしたVirtualBox上に、ゲストOSとしてCentOS7をインストールして検証しています。
- 構成
- ホストPC:Windows10 Pro
- 仮想化ソフト:VirtualBox バージョン 5.2.22 r126460 (Qt5.6.2)
- ゲストOS:CentOS Linux release 7.6.1810 (Core)
時刻をずらす
まずは、dateコマンドを実行して時間をずらしてみます。
# date
2019年 1月 3日 木曜日 12:02:30 JST
# date -s "10/26 09:00 1985"
1985年 10月 26日 土曜日 09:00:00 JST
# date
1985年 10月 26日 土曜日 09:00:01 JST
2019年1月3日→1985年10月26日になりました。
時刻ズレ状態が完了です。
ちなみに
ちなみに、この状態でyum update -y install
を実行したら成功しました。
# yum -y install update
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.tsukuba.wide.ad.jp
* extras: ftp.tsukuba.wide.ad.jp
* updates: ftp.tsukuba.wide.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ NetworkManager.x86_64 1:1.12.0-6.el7 を 更新
---> パッケージ NetworkManager.x86_64 1:1.12.0-8.el7_6 を アップデート
<略>
gitコマンド
git clone
を実行したところ、下記のとおり失敗しました。
# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/root/.rbenv'...
fatal: unable to access 'https://github.com/sstephenson/rbenv.git/': Peer's Certificate has expired.
時刻を合わせれば成功します。
# date -s "01/03 12:13 2019"
2019年 1月 3日 木曜日 12:13:00 JST
# date
2019年 1月 3日 木曜日 12:13:01 JST
# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/root/.rbenv'...
remote: Enumerating objects: 2744, done.
remote: Total 2744 (delta 0), reused 0 (delta 0), pack-reused 2744
Receiving objects: 100% (2744/2744), 515.63 KiB | 862.00 KiB/s, done.
Resolving deltas: 100% (1720/1720), done
rbenvコマンド
次はrbenvで試してみます。
再度時刻をずらし、rbenv install
を実行します。
# date -s "10/26 09:00 1985"
1985年 10月 26日 土曜日 09:00:00 JST
# date
1985年 10月 26日 土曜日 09:00:01 JST
# rbenv install -v 2.0.0-p353
/tmp/ruby-build.19851026090004.23100 ~
Downloading yaml-0.1.6.tar.gz...
-> http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz
curl: (60) Peer's Certificate has expired.
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
error: failed to download yaml-0.1.6.tar.gz
BUILD FAILED (CentOS Linux 7 using ruby-build 20181225-1-g095d9db)
こちらも時刻を合わせると成功します。
# date -s "01/03 12:47 2019"
2019年 1月 3日 木曜日 12:47:00 JST
# date
2019年 1月 3日 木曜日 12:47:01 JST
# rbenv install -v 2.0.0-p353
/tmp/ruby-build.20190103125202.23261 ~
Downloading yaml-0.1.6.tar.gz...
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 503012
Connection: keep-alive
Date: Wed, 02 Jan 2019 19:39:23 GMT
Last-Modified: Fri, 23 May 2014 08:48:21 GMT
ETag: "5fe00cda18ca5daeb43762b80c38e06e"
Accept-Ranges: bytes
Server: AmazonS3
Age: 29617
X-Cache: Hit from cloudfront
Via: 1.1 b9044b358673e38290bd0b6363352e43.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 7coOhXxt79B6-3LKk5EUbxgVSelUb8DPq2e9l_y3QOwB0ONIIHK8VA==
-> https://dqw8nmjcqpjn7.cloudfront.net/7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749
Installing yaml-0.1.6...
/tmp/ruby-build.20190103125202.23261/yaml-0.1.6 /tmp/ruby-build.20190103125202.23261 ~
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
<略>
何故か
# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/root/.rbenv'...
fatal: unable to access 'https://github.com/sstephenson/rbenv.git/': Peer's Certificate has expired.
git clone
のエラーが1行で読みやすいので、こちらを見ていきます。
Peer's Certificate has expired.
証明書の期限切れが出力されています。
実際に証明書の期限は切れていないのですが、クライアント(CentOS7)の時刻がずれていることで、
証明書の期限が正常に検証できず、証明書エラーとなっているようです。
最後に
いくら社内用のすぐに消すサーバであっても、時刻は合わせましょう。
いつもならしっかり行う時刻合わせを怠り、先日ハマりました。