Cloning a git repo on a Media Temple server
I've got a Media Temple server which already has git installed. How can I c开发者_开发问答lone files from a repository I have hosted on GitHub?
It is probably similar to cloning on a Media Temple server a repo hosted on Unfundle (process for which you have a comprehensive guide here)
The Media Temple part involves (supposing you already created the SSH keypair on your local machine and added it to GitHub):
- Create Your SSH Keypair on the Media Temple Server
This is similar to the setting up the keys on your local machine except that the path to the
.ssh
folder is a bit different.
It will vary depending on the hosting plan you have with Media Temple. Mine was like this:Instead of
~/.ssh
, it was/home/HOSTING_CODE/users/.home/.ssh
whereHOSTING_CODE
is the 5 digit number assigned to your hosting plan.You'll know what the path is once you execute the "
ssh-keygen -1 rsa
" command. It will be mentioned at the filename prompt.NOTE: Unlike on the local keygen, the remote server will require you to enter in the entire path from root.
SSH into your Media Temple server then proceed.
The following command will ask you for a filename and a password.
If you intend to have multiple key pairs (which you probably will at some point), then it's best to name them differently.
So provide a short descriptive filename each time you create a new key pair.
For unfuddle I use the SUBDOMAIN and "unfuddle", so for me it's "myproject_unfuddle
". You'll be adding this to the.ssh/config
file in a minute.Also, while you CAN use an empty passphrase, you should always provide a password.
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
$ Enter file in which to save the key (/home/HOSTING_CODE/users/.home/.ssh/id_rsa):
[provide a filename] <- create a short descriptive filename
[ie - myproject_unfuddle]
$ Enter passphrase (empty for no passphrase): [password] <- always use a password
$ Enter same passphrase again: [password confirmation]
$ Your identification has been saved in
/home/HOSTING_CODE/users/.home/.ssh/myproject_unfuddle.
$ Your public key has been saved in
/home/HOSTING_CODE/users/.home/.ssh/myproject_unfuddle.pub.
The key fingerprint is:
46:1b:99:56:77:0b:38:1e:35:92:de:94:58:b4:f3:d4 user@machine
The following will echo the public key to the screen. You'll need to copy this and paste it into unfuddle shortly.
$ cat /home/HOSTING_CODE/users/.home/.ssh/myproject_unfuddle.pub<
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwIuZA6ca9I1E2c6j1lbqvzDpZD2XQ5dRGVjeby1SGX+6
tyjA1zcN9mim9DXOWiX1wyUwnQdNR3qmzJwjlX1riLpXoEutZxRHsvWyeQFsrWM8B5rJk0U0HDEEH+/9
u0SjGZZq0ERZE+L999ZzAYp7voxD7L7zFqp+odqNMpLln4A98JTBI50q5tVBQBbkh8wXHKPI0xLB1N9u7
VCLB8zrR7/SC73/t3XicnhmaaPL8R+9GKyfRtjxAWyRGZiG+A9ZDXgQ9m6kNP2xS3AFi2jRvHfH2tnmy
+KD80sn9hwqTIMANVr2FjVloBHmi+FIHeL9qFbdI/4DCJMHt/hEdAw== user@machine
Next we'll need to add this key to the ssh config file. If you've never created the config file then it probably doesn't exist yet.
So open/create the config file:
$ pico /home/HOSTING_CODE/users/.home/.ssh/config
Once inside add the new entry:
$ IdentityFile /home/HOSTING_CODE/users/.home/.ssh/myproject_unfuddle
As you add additional keys you'll need to add them to the config file. This file basically tells the keychain which keys to look in when comparing the private and public keys you've generated.
Simply add new entries above or below the others:
$ IdentityFile /home/HOSTING_CODE/users/.home/.ssh/myproject_unfuddle
IdentityFile /home/HOSTING_CODE/users/.home/.ssh/some_other_key_name
Then hit CTRL-X to quit, which will prompt you to save the buffer (hit y) and then a file name (defaults to the name you opened it with (config) then hit return)
Add your SSH keypair to GitHub
clone the GitHub repo on the Media Temple server
SSH into your Media Temple server then proceed.
$ git clone gitRepoName@github.com:SUBDOMAIN/ABBREVIATION.git
You will be prompted for the password if the public key was found on GitHub.
精彩评论