一定期間更新がないため広告を表示しています
$ git clone git://github.com/RailsApps/rails3-mongoid-devise.git
以下、herokuの2つのアカウントを仮にjimmyとjackとする
$ heroku plugins:install git://github.com/ddollar/heroku-accounts.git
heroku-accounts installed
$ heroku accounts
No accounts found.
$ heroku accounts:add jimmy
Enter your Heroku credentials.
Email: jimmy@xxxxx.xxxxx
Password:Add the following to your ~/.ssh/config
Host heroku.jimmy
HostName heroku.com
IdentityFile /PATH/TO/PRIVATE/KEY
IdentitiesOnly yes
$ heroku accounts:add jack
Enter your Heroku credentials.
Email: jack@*****.*****
Password:Add the following to your ~/.ssh/config
Host heroku.jack
HostName heroku.com
IdentityFile /PATH/TO/PRIVATE/KEY
IdentitiesOnly yes
$
次に、sshのkeyを作成してIdentityFile の /PATH/TO/PRIVATE/KEY にPATHを記載する
◇sshのkey
keyを1つは紛失し、1つは複数アカウントの試行錯誤中に削除したため、最初から作成しなおし。
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/jimmy/.ssh/id_rsa): /Users/jimmy/.ssh/id_rsa_jimmy
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/jimmy/.ssh/id_rsa_jimmy.
Your public key has been saved in /Users/jimmy/.ssh/id_rsa_jimmy.pub.
The key fingerprint is:
79:cd:45:ee:37:da:18:66:3f:c5:6e:53:c6:44:f5:a3 jimmy@xxxxxxxxxx
The key's randomart image is:
+--[ RSA 2048]----+
| ..+|
| . +.|
| . o.+.o|
| + + ..+=o.|
| + S o .= ..|
| + + E |
| . |
| |
| |
+-----------------+
$
jackに対しても同様に
$ ssh-keygen -t rsa
して
/Users/jimmy/.ssh/id_rsa_jack
を作成
上記のheroku accounts:add実行時のコメントに従い、~/.ssh/config を以下のように編集
Host heroku.jimmy
HostName heroku.com
IdentityFile /Users/jimmy/.ssh/id_rsa_jimmy
IdentitiesOnly yesHost heroku.jack
HostName heroku.com
IdentityFile /users/jimmy/.ssh/id_rsa_jack
IdentitiesOnly yes
◇git clone
$ heroku accounts:default jimmy
$ git config heroku.account
jimmy
$ heroku accounts
* jimmy
jack
$
で、適当なディレクトリを作成してそこでgit cloneすると
$ git clone git@heroku.com:myapp_jimmy.git .
Cloning into ....! Your key with fingerprint 79:cd:45:ee:37:da:18:66:3f:c5:6e:53:c6:44:f5:a3 is not authorized to access myapp_jimmy.
fatal: The remote end hung up unexpectedly
$
heroku keys:addが必要
$ heroku keys
No keys for jimmy@xxxxx.xxxxx
$ heroku keys:add
Found the following SSH public keys:
1) id_rsa_jimmy.pub
2) id_rsa_jack.pub
Which would you like to use with your Heroku account? 1
Uploading SSH public key /Users/jimmy/.ssh/id_rsa_jimmy.pub
$
再度git clone
$ git clone git@heroku.com:myapp_jimmy.git . Cloning into .... Permission denied (publickey). fatal: The remote end hung up unexpectedly $
googleさんで調べるとssh-addが必要とのことで
$ ssh-add -l
The agent has no identities.
$ ssh-add ~/.ssh/id_rsa_jimmy
Enter passphrase for /Users/jimmy/.ssh/id_rsa_jimmy:
Bad passphrase, try again for /Users/jimmy/.ssh/id_rsa_jimmy:
$
ssh-agenetが必要らしい
$ ps ax | grep ssh-agent
536 ?? S 0:00.07 /usr/bin/ssh-agent -l
739 s000 R+ 0:00.00 grep ssh-agent
$ eval 'ssh-agent'
SSH_AUTH_SOCK=/tmp/ssh-CpJmPKiFmG/agent.740; export SSH_AUTH_SOCK;
SSH_AGENT_PID=741; export SSH_AGENT_PID;
echo Agent pid 741;
$ ps ax | grep ssh-agent
536 ?? S 0:00.07 /usr/bin/ssh-agent -l
741 ?? Ss 0:00.03 ssh-agent
743 s000 R+ 0:00.00 grep ssh-agent
$ ssh-add ~/.ssh/id_rsa_jimmy
Enter passphrase for /Users/jimmy/.ssh/id_rsa_jimmy:
Identity added: /Users/jimmy/.ssh/id_rsa_jimmy (/Users/jimmy/.ssh/id_rsa_jimmy)
$複数アカウントを使う場合にはhttp://journal.sooey.com/162