I would like to clone GCP "Cloud Source Repositories" in AWS instance using GCP service account(IAM). I wanted to close using "git clone" command. Please let me know how to do it?
You can find the find the official documetation Cloning a repository.
You can clone using SSH authentication, Google Cloud SDK or Manually generated credentials.
I was able to clone the Cloud Source Repo to AWS:
I generate the ssh keys:
ssh-keygen -t rsa -C "user#support.com"
I register a public key link.
I cloned the repo:
git clone ssh://useri#support.com#source.developers.google.com:2022/p/project/r/test
Related
I am trying to clone a repo from Azure DevOps on Linux VM on windows 11 using SSH. It is asking me for a username and password for https://XX.visualstudio.com. The steps are below. Am I missing anything?
Created a VM Ubuntu 18.04 LTS using Hyper V
Installed git
Generated a key pair
added a public key in Azure DevOps
and git clone the repo
I was not able to create and edit ~/.ssh/config, it is not present, some solutions were suggested to edit it.
Please make sure we are using SSH URL when cloning.
Enter your passphrase for SSH key.
For more details about how to generate a new SSH key and set passphrase, you could refer to this doc: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
I try set up jenkins for automatically execute git pull from bitbucket. I created an SSH on repository and executed ssh -T git#bitbucket.org and got response:
authenticated via a deploy key. You can use git or hg to connect to Bitbucket. Shell access is disabled.This deploy key has read access to the following repositories:
If I try execute ssh git pull the console does infinite loading.. Why?
Did you clone repository? You should be able to login to Bitbucket web interface and in you profile add your public SSH key.
Then you can clone repository. From Bitbucket webinterface --> repo --> click on clone. This will pop up window with ssh command to clone repository.
Once you repo is cloned, you should be able to use
git pull
...edit,add,commit
git push
There is no need to manually open SSH connection - git will do it itself. You just need to tell git to pull a specify from which repository. Git will parse the URL, and invoke SSH if needed.
And this is the best practice to disable shell access to git hosts. See e.g. https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
I Need to do a git pull using https url as a oneline command . this command I need to integrate in a bash script . But all the time it is asking the usernmae and password .
The repository is in AWS codecommit
Try this:
git clone https://username:password#git-codecommit.us-east-1.amazonaws.com/v1../repos../..
This way worked for me for CodeCommit (AWS) repository
Check this link: Enter user password in command
As is described perfectly in that post, you basically have three options:
Store the password in .netrc file (with 600 permissions). Make sure you clone the repo specifying the username in the url.
Clone the repo with https://user:pass#domain/repo . Take into account that your password will be visible in several places...
Use the credential helper.
As an update, AWS has released their remote git remote codecommit. With proper IAM setup, you can do oneline pulls without even passing username and passwords. This is now the recommended method by AWS. It can be setup on your local or on a container that's running in an AWS Pipeline for example.
i.e. git clone codecommit://HelloWorldRepo myLocalHelloWorldRepo
And then you can git pull as normal.
Full documentation is here:
https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html
first of all, apologize for dummy questions that I might throw here. It would be nice if you could point the directions where should I go from here.
I'm totally new to version control(as well as git) and cloud system. However, it came to the point that I have to develop php web based application on AWS EC2 instance and make codes contributable for future developers.
I did successfully create EC2 instance that run PHP/MySQL and map the domain with Elastic IP. So the website is now publicly accessible via port 80.
I also installed git using $sudo yum install git and configed user.name and user.email
I then, go to root folder of the website (e.g. public_html) and run ‘git init’ which create the fold “.git” and I then add file using “git add .” and commit “git commit -m ‘initial upload’”
Is that the right way to go? Would it be ok to have the project folder sitting on /public_html (where accessible from anyone).
If above is ok, then where should I go from here?
I would like to have git server running on EC2 that allow developers to connect from their local machines (e.g. Eclipse) while being able to keep the backup and compare the different between codes.
What detail do I suppose to give developers so that they can connect to git server and working on project?
I quick direction or few keywords to do more research would help.
look here for more information on setting up git on amazon ec2
to allow developers to use you git, you just need to give them the git server url.
Direct quote from the site i'm linking to.
"First and foremost, you need to add your EC2 identity to the ssh
authentication agent. This prevents problems with git later, namely
getting the error “Permission denied (publickey).” when trying to do a
git push to the EC2 repository.
ssh-add path/to/privateEC2key.pem
Now you can go ahead and create the git repository on the EC2
instance.
ssh username#hostname.com
mkdir the_project.git
cd the_project.git
git init --bare
So not much going on here, all we do is create an empty repository and
then leave. Now, on the local machine, you do something like the
following:
cd the_project
git init
git add .
git commit -m "Initial git commit message"
git remote add origin username#hostname.com:the_project.git
git config --global remote.origin.receivepack "git receive-pack"
git push origin master
The ‘git config’ command is a fix that I found necessary to be able to
push to the EC2 repository."
The mentioned link by Alex gives a good starting point to setup git on ec2. But I followed a little different approach as mentioned here. link. Direct Quotes from the page:
"Connecting with SSH without a PEM key" : So either you add the ec2 private key and add it as a entity in your ssh authentication agent or create a new ssh key for your user and use that. Steps to be followed are:
Create SSH Key
First up you will need to navigate to your .ssh folder on your local machine :
cd
cd .ssh
if this folder doesn’t exist use mkdir to make it.
Once in your ssh folder on your local machine which should be in /Users/yourusername/.ssh generate your key by executing the following.
ssh-keygen -t rsa -b 1024
When prompted enter the file name to save the key enter id_rsa_aws, when prompted to enter a password leave blank.
In your .ssh directory execute the following command and copy the output to paste later.
cat id_rsa_aws.pub
Now connect to you AWS instance using you PEM key
ssh -i path/to/yourkeyname.pem ubuntu#xx.xxx.xxx.xxx
Once in
echo 'the key you copied from id_rsa_aws.pub' >> .ssh/authorized_keys
chmod 640 .ssh/authorized_keys
chmod 750 .ssh
Now you go to your machine and type
cd desired directory
git clone ubuntu#xx.xxx.xxx.xxx:<path_to_your_just_created_git_server>
If you did all the above mentioned steps correct, the only warning you might get is
warning: You appear to have cloned an empty repository.
That's ok. Now you can copy all your code into the clone directory, and follow the following steps:
git add .
git commit -m "Initial commit"
git push origin master // If working on master branch
i created a GitHub gist with all the details hope it helps
https://gist.github.com/eslam-mahmoud/35777e4382599438023abefc9786a382
//add your EC2 .pem file to ssh kys
ssh-add ~/aws/mypemfile.pem
//create bare repo on AWS EC2 webserver and deploy on demand
mkdir ~/git/the_project
cd ~/git/the_project
git init --bare
//create local repo and track remote one
cd ~/git/the_project
git init
git add .
git commit -m "Initial git commit message"
git remote add aws ubuntu#1.1.1.1:~/git/the_project
git config --global remote.origin.receivepack "git receive-pack"
git push aws master
//create tag
git tag -a v0.1 -m "my version 0.1"
//push tags
git push aws --tags
//Or you have one so you push your updates
git remote add aws ubuntu#1.1.1.1:~/git/the_project
git config --global remote.origin.receivepack "git receive-pack"
git push aws master
//create tag
git tag -a v0.1 -m "my version 0.1"
//push tags
git push aws --tags
//on server create another local repo that track the bare one to deploy
git clone ~/git/the_project
cd ./the_project
//checkout tag
git checkout v0.1
//install clear cache ...
npm install
I installed the gerrit service on a ubuntu server,and my PC as client.
I created a git repo on my PC(with msysgit),and the question is :how can I upload the git repo to the Ubuntu server?Should I do some work on Ubuntu server first(i just installed gerrit and git service )?
First, you need to create the project on the Gerrit server using gerrit create-project.
Next, edit the project permissions if necessary to add the following for your user (Administrators group, probably):
Create reference
Forge committer identity
Forge author identity
This allows you to upload an existing history, perhaps committed by different people, bypassing the need to review every commit you select.
Finally, push your code:
git remote add gerrit gerritserver:project
git push gerrit master:refs/heads/master