ล็อกอินด้วย user ssh
ssh-keygen
at the command line.
1 2 3 |
$ ssh-keygen //Generating public/private rsa key pair. //Enter file in which to save the key (/Users/emmap1/.ssh/id_rsa): |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/emmap1/.ssh/id_rsa): Created directory '/Users/emmap1/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/emmap1/.ssh/id_rsa. Your public key has been saved in /Users/emmap1/.ssh/id_rsa.pub. The key fingerprint is: 4c:80:61:2c:00:3f:9d:dc:08:41:2e:c0:cf:b9:17:69 emmap1@myhost.local The key's randomart image is: +--[ RSA 2048]----+ |*o+ooo. | |.+.=o+ . | |. *.* o . | | . = E o | | o . S | | . . | | . | | | | | +-----------------+ |
~/.ssh
to view the key files.
1 2 |
$ ls ~/.ssh //id_rsa id_rsa.pub |
1 2 |
$ eval `ssh-agent` //Agent pid 9700 |
ssh-add
followed by the path to the private key file:
1 2 |
$ ssh-add ~/.ssh/<private_key_file> // ssh-add ~/.ssh/id_rsa |
id_rsa.pub
with the public key file name.
1 |
$ cat ~/.ssh/id_rsa.pub |
จากนั้นก็ทำการ Clone มาที่ Server
1 |
git clone git@bitbucket.org:project/project.git . |
* ใส่ . ตามหลังเพื่อไม่ให้ เอาโฟลเดอร์ของ Project มาด้วย
ดูเพิ่มเติม
https://serverfault.com/questions/737595/git-clone-from-bitbucket-org-on-ec2-server-using-ssh-keys
https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html#SetupanSSHkey-ssh2