$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/pi/.ssh/id_rsa):← Enter
Created directory '/home/pi/.ssh'. ← ~/.ssh がない場合、ディレクトリを作成します
Enter passphrase (empty for no passphrase): ← Enter
Enter same passphrase again: ← Enter
Your identification has been saved in /home/pi/.ssh/id_rsa.
Your public key has been saved in /home/pi/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:pi@raspberrypi
The key's randomart image is:
$ ssh -T git@bitbucket.org
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 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 'bitbucket.org,131.103.20.167' (RSA) to the list of known hosts.
logged in as xxxxxxxx.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
3.クライアント側(Ubuntu)の設定
vi ~/.ssh/config
Host bitbucket.org
HostName bitbucket.org
IdentityFile ~/.ssh/id_rsa
User xxxxxx
TCPKeepAlive yes
IdentitiesOnly yes
$ cd /path/to/your/projectA
$ git push -u origin master
追記
【事前準備】の①を実行すると以下の追加は不要でした。
HTTPSのほうは、パスワードを聞いてきたが、SSHはパスワードなしでPushできました。
ここでPushしたら以下のようなメッセージがでたので、
$ git config –global push.default matching
を追加
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
これにより、上記のエラーはでなくなったのですが、Pushすると
まだ以下のエラーが残ってました。
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
Everything up-to-date
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/pi/.ssh/id_rsa):← Enter
Created directory '/home/pi/.ssh'. ← ~/.ssh がない場合、ディレクトリを作成します
Enter passphrase (empty for no passphrase): ← パスフレーズを入力します
Enter same passphrase again: ← もう一度パスフレーズを入力します
Your identification has been saved in /home/pi/.ssh/id_rsa.
Your publickey has been saved in /home/pi/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:pi@raspberrypi
The key's randomart image is:
「./ssh/id_rsa.pub」の内容を
githubのpersonal settingの「SSH Public Keys」に登録する
3.SSHで接続してみる。
$ ssh -l git -i ~/.ssh/github_id_rsa github.com
:
:
Enter passphrase forkey'/home/pi/.ssh/id_rsa : さっきのパスフレーズ
:
Connection to github.com closed.
$ vi ~/.ssh/config
Host github.com
HostName github.com
IdentityFile ~/.ssh/github_id_rsa
User git