LoginSignup
1
1

More than 5 years have passed since last update.

直接ネットワークに接続されていない環境でyumとgitコマンドを通す方法

Last updated at Posted at 2018-04-09

プロキシサーバを介してyum,gitを叩く

WEB1,WEB2環境にミドルウェアをインストールしないといけないのに、以下みたいな構成だったので、yumとかgitが通らなかった。
手動でインストールする手もあるが、依存性とか怖いな・・・というときに使う設定方法。

                                                  +
                                                  |
                                                  |
                                                  |
                                                  |       Internet
+-----------+             +-----------+           |
|           |             |           |           |
|           |             |           |           |
|    WEB1   +-------+-----+   Proxy   <----------->
|           |       |     |           |           |
|           |       |     |           |           |
+-----------+       |     +-----------+           |
                    |                             |
                    |                             |
+-----------+       |                             |
|           |       |                             |
|           |       |                             |
|    WEB2   +-------+                             |
|           |                                     |
|           |                                     |
+-----------+                                     |
                                                  |
                                                  |
                                                  |
                                                  +

図はここで作成
ASCIIFlow Infinity

外部ネットに直接つながっているサーバから、SSHトンネルを掘る

上記の図でいうとWEB1,WEB2から以下のコマンドを打つ

$ /usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -i /root/.ssh/id_rsa -D 10080 {hostname}(上記でいうとProxy)

このコマンドを打つと、Control + Cで止めるまで何も打てなくなるので、最後に & を付けておくか、ターミナルを複製しておくとよいです。

yumのconfに指定のProxyを利用して接続することを明示

以下の行をyum.comfに追加します。

yum.conf
proxy=socks5h://localhost:10080 

git側のプロキシ設定

gitはコマンドでプロキシの設定が完了する。楽ね:relaxed:

$ git config --global http.proxy http://proxy.example.com:8080
$ git config --global https.proxy http://proxy.example.com:8080

あとはgit clone とか yum install とか打てはちゃんと通るようになってるはずです。

1
1
0

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
1
1