0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

真っ更なOSにGitHubのDeploy keysでソースをcloneするまで

0
Posted at
  • 諸事情により踏み台サーバーにポートフォワーディングできない環境だったため、マイグレーション用踏み台サーバーへGitHubからソースをcloneしたい

  • PATを発行せずリポジトリに対してcloneする方法としてDeploy Keysを選択した

  • 真っ更と言いつつgit, sshコマンドは入っていることを前提とする

流れ

  • ホスト(OS)のsshキー作成
  • GitHubでDeploy keyを追加
  • Deploy keyをホストに配置
  • clone

ホスト(OS)のsshキー作成

  • ssh-keygen -t ed25519 -C "deploy-key" -f ~/.ssh/deploy_key
    • -C は任意のコメント
    • ~/.ssh/deploy_key に秘密鍵が生成される

GitHubでDeploy keyを追加

  • リポジトリ内で Settings > Deploy Keys > Add deploy key
    • title: 任意。踏み台サーバーのリソース名にしておいた
    • key:~/.ssh/deploy_key.pubを貼り付ける
    • Allow write access: チェックしない。cloneするだけのため

Deploy keyをホストに配置

  • SSH設定ファイル作成
    $ vim ~/.ssh/config
~/.ssh/config.sh
   Host github.com
       HostName github.com
       User git
       IdentityFile ~/.ssh/deploy_key
       IdentitiesOnly yes
   $ chmod 600 ~/.ssh/deploy_key
   $ chmod 644 ~/.ssh/deploy_key.pub
   $ chmod 600 ~/.ssh/config
    $ ssh -T git@github.com
    Hi {リポジトリ名}! You've successfully authentic ated, but GitHub does not provide shell access.'
  • clone
    $ git clone git@github.com:~~~
    
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?