GitHubにログインしていることが前提です。
(1) 右上のリポジトリ作成ボタンをクリック
(2)リポジトリ名と公開/非公開設定、そして「READMEファイルをどうするか」を設定
(3) リポジトリが作成されていることを確認
(4) SSHにてGitにアクセスする情報を確認
(5) "git clone"するサーバでSSHのキーを作成
# cd # cd .ssh/ # ssh-keygen -C suz-lab-centos-ami@suz-lab.com Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx suz-lab-centos-ami@suz-lab.com The key's randomart image is: +--[ RSA 2048]----+ | oo | | E . | | * + . | | = X . | | . OS+ | | +.o o | | . o.. | | .o+ | | .o. | +-----------------+※途中で入力したパスフレーズはGitHubに公開鍵を設定するときにも必要となります。
(6) 作成された鍵を確認
# ls -1 authorized_keys id_rsa id_rsa.pub
- id_rsa : 秘密鍵
- id_rsa.pub : 公開鍵 (後でGitHubに登録します)
(7) 秘密鍵の確認
# cat id_rsa -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,2C57B454EEAB0A3F o8LbCiHhB7ME6/+eYXyQ/g/3bpzZi1aFgA4/BaMIvZWRs9UkPI12fJZI95zuqIqB ... 2mM0KOFDe3fP0W/fe7j1sa/bRqfTx+YQ5n7yscQGTbVVM2j3Nld8yA== -----END RSA PRIVATE KEY-----
(8) 公開鍵の確認
# cat id_rsa.pub ssh-rsa AAAAB3Nz...== suz-lab-centos-ami@suz-lab.com
(9) GitHubにテストアクセス
# ssh git@github.com The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts. Permission denied (publickey).※GitHubに公開鍵が登録されてないので"Permission denied (publickey)"となります。
ちなみにこの時、"GitHub"の公開鍵が"known_hosts"に登録されます。
# ls -1 authorized_keys id_rsa id_rsa.pub known_hosts
登録内容か下記のような感じです。
# cat known_hosts github.com,xxx.xxx.xxx.xxx ssh-rsa AAAAB3Nz...==
(10) 公開鍵の登録も右上のアカウント設定をクリック
(11) 左メニューの"SSH Keys"をクリック
(12) 公開鍵を追加するために"Add SSH key"をクリック
(13) タイトルと公開鍵を入力
(14) パスフレーズを入力
(15) 公開鍵が追加されたことを確認
(16) 再度GitHubにテストアクセス
# ssh git@github.com Enter passphrase for key '/root/.ssh/id_rsa': PTY allocation request failed on channel 0 Hi suz-lab! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.※GitHubに公開鍵が登録されたので"Permission denied (publickey)"は表示されません。
(17) "git clone"でリポジトリのコピーを取得
# cd /opt/ # git clone git@github.com:suz-lab/suz-lab-centos-ami.git suz-lab Initialized empty Git repository in /opt/suz-lab/.git/ Enter passphrase for key '/root/.ssh/id_rsa': remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done.
(18) リポジトリのコピーができていることを確認
# ls -1 aws suz-lab # cd suz-lab/ # ls -1a . .. .git README.md suz-lab
これで"SUZ-LAB CentOS AMI"に組み込むツールをGitHubで管理できるようになったぞ...
--------
http://www.suz-lab.com











0 コメント:
コメントを投稿