Organizationを作って、月21ドルを支払うとIP制限が可能。
設定URL
https://github.com/organizations/{organization_name}/settings/security
118.XXX.184.131/32
こんな感じでIPを追加して、
Enable IP allow list にチェックを入れてSave押下で有効化される。
テストをしてみた。
異なるIPからOrganizationページに接続しようとしたら、
https://github.com/{organization_name}/{repository_name}
このIPは許可されていませんって表示された。
Access forbidden from this IP address
ちゃんと効いている。
あと、まず許可されているIPからアクセスして、Organizationページを表示させた後に、許可されていないIPに切り替えて、再表示させたら、同様に「このIPは許可されていません」が表示された。
ちゃんと効いている。
それと、レポジトリだけでなくて、Organizationの設定ページもIP制限の対象になるから、間違ったIPを入れて登録したら詰むっぽい。
https://github.com/organizations/{organization_name}/settings/security
SSH接続の場合も効いてた。
ERROR: The repository owner has an IP allow list enabled, and XXX.XXX.XXX.XXX is not permitted to access this repository.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
参考
Organization に対する許可 IP アドレスを管理する - GitHub Docs