Squid は HTTP Proxy です。加えて、FTP over HTTP や SSH over HTTP といった技術を併用することで、FTP や SSH プロキシとしても機能します。本ページでは、
- すべて HTTP 通信で GCP Cloud Source Repositories にアクセスする方法と、
- SSH over HTTP を併用することで GCP Cloud Source Repositories にアクセスする方法
の二つを記載します。いずれも squid 経由とします。
Cloud SDK を用いる方法
Cloud SDK は GCP のための HTTP クライアントです。HTTP proxy である squid を経由して通信できます。
補足: Block access to consumer accounts による制限の対象となります。
環境変数を設定しておきます。
export http_proxy=http://localhost:3128
export https_proxy=http://localhost:3128
レポジトリを作成および clone します。
gcloud source repos create hello-world
gcloud source repos clone hello-world
すべて squid 経由の通信となります。
CONNECT oauth2.googleapis.com:443
CONNECT sourcerepo.googleapis.com:443
Git は SSH プロトコルと HTTP プロトコルの二つをサポートしています。上記設定を行なうと、HTTP プロトコルを利用するように clone されることが分かります。
vagrant@debian11:~/hello-world$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[credential "https://source.developers.google.com/"]
helper =
helper = !gcloud auth git-helper --account=username@gmail.com --ignore-unknown $@
[remote "origin"]
url = https://source.developers.google.com/p/myproject-20210411/r/hello-world
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
参考資料: Quickstart: Create a repository
SSH over HTTP を用いる方法
GCP Cloud Source Repositories は Git の SSH プロトコルによる通信にも対応しています。
補足: SSH 鍵による認証であるため、Block access to consumer accounts による制限の対象外となります。
参考資料: Setting up local authentication
connect-proxy のインストール
SSH プロトコルによる GCP Cloud Source Repositories との通信を squid 経由で行なうためには、SSH over HTTP という技術を併用する必要があります。具体的には connect-proxy
を利用します。
sudo apt install connect-proxy
インストールされた connect
または connect-proxy
コマンドを利用します。
vagrant@debian11:~$ ls -l `which connect`
lrwxrwxrwx 1 root root 13 Dec 31 2020 /usr/bin/connect -> connect-proxy
ssh config の設定
SSH 鍵のペアを作成して、公開鍵を GCP に登録します。
ssh-keygen -t rsa -C "username@gmail.com"
秘密鍵を参照できるような SSH config を作成します。localhost の squid に対して SSH over HTTP 通信を行なうように ProxyCommand
を設定することがポイントです。
vagrant@debian11:~$ cat .ssh/config
Host my-gcp-repos
HostName source.developers.google.com
User username@gmail.com
IdentityFile ~/.ssh/id_rsa
Port 2022
ProxyCommand connect -H localhost:3128 %h %p
squid 設定変更
ポートおよびメソッドによる制限を squid で設定している場合には、TCP 443 に加えて TCP 2022 が必要となるため許可しておきます。
acl Safe_ports port 443 # https
acl Safe_ports port 2022 # SSH for GCP Cloud Source Repositories
acl SSL_ports port 443
acl SSL_ports port 2022
git-clone
以下のように clone します。
git clone ssh://my-gcp-repos:/p/myproject-20210411/r/hello-world
確かに squid 経由となっていることが squid の access.log から確認できます。
CONNECT source.developers.google.com:2022
SSH プロトコルを利用するような git 設定になっていることも確認できます。
vagrant@debian11:~/hello-world$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = ssh://my-gcp-repos:/p/myproject-20210411/r/hello-world
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
関連記事
- GKE における Node および Pod の autoscalingGoogle Kubernetes Engine (GKE) における autoscaling について、用語の意味を整理します。 GKE の機能による Node の autoscaling GKE のクラスタには Standard と Autopilot の二種類が存在します。 Autopilot の場合は Node は Google によって管理されるため、自動で autoscaling され...
- Snowflake におけるネットワーク関連の設定本ページではネットワーク関連の設定について記載します。 Network Policy によるアクセス元 IP 制限 IPv4 で指定します。IPv6 は 2021/9/21 時点では利用できません。 allowed list で許可されていない IP は block されます。 allowed list が /24 等で指定されており、その一部を
- VPC Service Controls に関する雑多な事項の整理VPC Service Controls (VPC-SC) に関する雑多な事項を記載します。 Private Google Access の基本形 Private Google Access は外部 IP を持たない VM のための機能です。VPC の機能ですが、VPC-SC と関連するため基本事項を記載します。 [Private Google Access](ht
- AWS IAM Role を GCP から STS 認証で利用する設定例GCP から AWS IAM Role を利用するための設定例を記載します。 GCP Service Account の作成 Service Account を作成して Unique ID を確認します。 AWS IAM Role の作成 Trust relationship の設定は Web Identity を選択します。Identity Provider
- Amazon Comprehend を GCP VPC 内から実行する設定の例 (Public Internet 接続なし)GCP DLP に相当する AWS サービスに Amazon Comprehend が存在します。GCP VPC 内から Public Internet を経由せずに利用する設定の例を記載します。 AWS VPC と GCP VPC の作成 クラウド 項目 値 AWS VPC region ap-northeast-1 AWS VPC CIDR 10.2.0.0/16 AWS ap-north