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.

1 comment:

How to Recover SonarQube Admin password | How to unlock SonarQube admin password in Postgres SQL

Let's say you have setup SonarQube using Docker or Docker Compose, you have forgotten the admin password for SonarQube. This article hel...