🙌

Githubクローン

2021/06/15に公開

EC2にRailsアプリをクローンするときの方法

$ vim .gitconfig

#gitconfig
[user]
  name = (gitに登録した自分の名前)
  email = (git登録時の自分のメアド)

[url "github:"] 
    InsteadOf = https://github.com/
    InsteadOf = git@github.com:

$ cd /
$ sudo chown [username] var 
$ cd var
$ sudo mkdir www
$ sudo chown [username] www 
$ cd www
$ sudo mkdir rails
$ sudo chown [username] rails
$ cd ~
$ mkdir .ssh (#既に生成されている場合もあります。)
$ chmod 700 .ssh
$ cd .ssh
$ ssh-keygen -t rsa

-----------------------------
Enter file in which to save the key ():test(アプリ名など)
Enter passphrase (empty for no passphrase): 空エンター
Enter same passphrase again: 空エンター
-----------------------------

$ vim config

#config
Host github
  Hostname github.com
  User git
  IdentityFile ~/.ssh/test_rsa (#秘密鍵の設定)

$ cat test.pub
公開鍵をコピーしておく

Githubにいき、
アイコンから「Settings」 → 「SSHandGPGKey」 → 「New SSHKey」
Titleには公開鍵の名前、Keyにはコピーした公開鍵。

chmod 600 config
$ ssh -T github
$ cd /var/www/rails
$ git clone git@github.com:・・・・・・・・・・・・・・・・

Discussion