Friday, February 8, 2019

Connect EC2 instance to Git Repo - How to connect EC2 instance to BitBucket

Let us see steps for connecting an EC2 instance to Git repo such as BitBucket.

1. Create SSH keys in EC2 instance first by executing below command:

ssh-keygen
(no need to give any password)

The above command will create two keys - public key(is_rsa.pub) and private key(is_rsa)

2. Copy public keys from .ssh folder

sudo cat ~/.ssh/id_rsa.pub

3. Now go to Bitbucket, click on avatar and click on Bitbucket Settings.
 4. Click on Add Key and copy the content of public keys


5. Now click on repo you want to make a code change. Click on Clone and copy the SSH url. Do not select HTTPS Url. The url will be from your repo you created under Clone link.


6. Go to your EC2, perform below command:

git clone <ssh_url_from_bitbucket_repo_you_copied>

7. Click yes to connect

8. Now you will see a folder with reponame created.

9. You can cd into reponame and make some code changes..once you make a code change, you can commit into Bitbucket by entering below comments

10. git add *

11. got commit -m "My first commit" 

12. git push

Now go to Bitbucket refresh you will see the code changes in BitBucket.

No comments:

Post a Comment

How to create Ubuntu 22.0.4 Virtual Machine (VM) in Azure? | Create Ubuntu 22.0.4 VM in Azure | How to connect to Azure VM from your local machine

 How to Create Ubuntu 22.0.4 Virtual Machines(VM) in Azure portal? Creating Virtual Machine is easy and straight forward in Azure Cloud. Let...