ssh -p your_port you@your_ip_addressNow, see if you already have git installed:
which gitIf your machine has git installed you'll see its path printed to your screen. Else, you'll need to install it:
sudo aptitude install gitYou'll be prompted regarding incoming file size. Enter "yes". Now run:
which gitYou'll see the program's path printed to your screen:
/usr/bin/gitNow we need to check and see if you have an ssh key pair on your machine or if we need to create one. To start off, we need to examine your remote machine. Run the following command:
cat ~/.ssh/id_rsa.pubIf the above command prints "No such file or directory", then you'll need to generate an ssh key pair before continuing. If the previous command printed a bunch of funny looking letters and numbers, then you already have an ssh key pair on your local machine that we can make use of!
Okay, so if your machine doesn't already have an ssh key pair on file, we can easily create one. Enter the following command:
ssh-keygen -t rsa -C "your_email@your_domain.com"You'll be prompted with the following:
Enter file in which to save the key (/Users/you/.ssh/id_rsa):Just press enter and "~/.ssh/id_rsa" will be used (which is what we want).
Next, you'll be prompted with the following:
Enter passphrase (empty for no passphrase):Press enter twice to generate a key pair without a passphrase.
Now, at this point, everybody should have an "~/.ssh/id_rsa.pub" file on their remote machine. Next, log in to your BitBucket or GitHub account.
For BitBucket follow these steps:
- Step 1) Go to https://bitbucket.org/account/user/abovemarket/ssh-keys/
- Step 2) Click "Add key" as shown in the following screenshot:
-
Step 3) Print your machine's id_rsa.pub file content on the command line so you can manually copy it into memory:
cat ~/.ssh/id_rsa.pub
After copying it, without getting a single extra character accidentally added, paste it into your BitBucket account as shown in the following screenshot:
For GitHub follow these steps:
- Step 1) Go to https://github.com/settings/ssh/
- Step 2) Click "Add SSH key" as shown in the following screenshot:
-
Step 3) Print your machine's id_rsa.pub file content on the command line so you can manually copy it into memory:
cat ~/.ssh/id_rsa.pub
After copying it, without getting a single extra character accidentally added, paste it into your GitHub account as shown in the following screenshot:
git config --global user.name "Your Full Name Here"
git config --global user.email your_repo_email@your_domain.comNow, clone your project!
For BitBucket:
git clone git@bitbucket.org:your_username/your_project.git your_domain.comFor GitHub:
git clone git@github.com:your_username/your_project.git your_domain.comIn either case, you'll be prompted about "The authenticity of host...", enter "yes".
Boom! You're done! Way to go!
Lastly, if you're coming from my post titled, "How do I set up Apache virtual hosts on a Debian based Linux machine and configure to support HTTPS?", you can get back to it here: http://oneqonea.blogspot.com/2013/04/how-do-i-set-up-apache-virtual-hosts-on.html
Hi John,
ReplyDeleteReally great posts on this site. I've followed a few- really good work. Just wondering on this one....could this be a good replacement to using sftp to get my files across to my server? Would I make changes, push to git hub and then push to my server via git somehow....not at all familiar with git hence the question.
Thanks
Heyyoo,
DeleteThanks. I'm glad you dig the site.
Yes. Git is an awesome alternative to using sftp to get your files across to your server. You'll work day to day git pushing and pulling from your local machine to Bitbucket/Github. Once you've done the "push" to Bitbucket/Github that you'd like to see on your server, you can ssh into your server and run a git pull (note: you'll need to set up your server similarly to how you set up your local machine with Bitbucket/Github i.e. you'll need to register the identity of your server with Bitbucket/Github (server's id_rsa.pub) or use read-only deploy keys ).
I think this answers your question. If not, let me know!