How to configure git in ec2 with my local machine?
I have installed git in ec2 instance and in my local machine.
I have used below commands in ec2 after installing git.
cd home/username/git mkdir newproject.git cd newproject.git git init --bare cd /var/www/html/projectname git init git add --all git commit -m ”first commit” git remote add origin email@example.com(ec2):/home/username/newproject.git
Below are the commands i executed after installing git.
Cd /var/www/html/projectname git init git add --all git commit -m ”first commit” git remote add origin firstname.lastname@example.org(EC2):/home/username/newproject.git
Now when i give the below command from my local machine
git pull origin master
i am getting below error.
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights
And then from my local machine when i give
git push origin master
i am getting below error:
ssh: Could not resolve hostname ip-220.127.116.11(EC2) Name or service not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
note: i usually login to ec2 through ssh by using a key.pem file.
someone guide me how to configure git from local to ec2 machine?
4 Solutions collect form web for “How to configure git in ec2 with my local machine?”
You need to change the config file for the ssh server and restart the server.
then restart the ssh server:
Using a key file with SSH is done with the
-i option, but you can’t use it with git.
The solution is to configure SSH to use this key. Set in your
Host THE_EC2_HOSTNAME_OR_IP IdentityFile /path/to/your/key.pem
Then when using a remote
username@THE_EC2_HOSTNAME_OR_IP:/path/to/repo.git, it will automatically use the
key.pem for authentication.
But be sure to use the EC2 instance IP or public DNS (your hostname is a little bit weird with parenthesis
as said by @saravanan..
have a password authentication so that you can have a secured file transfers.
go to your sshd_config file and change password authentication to yes.
then restart your ssh server.then create a new bare and try it..
to create a new password
sudo passwd username
this will create a new password so that you can use this instead of .pem file..This is not the only way but it will work
First, create an account on GitHub
Just you need to first install gitHub. If Windows download exe and if Ubuntu than you need to run
apt-get install git
The above command will set up git env in your local Machine
You need to configure git user
git config --global user.name "Mayank Dwivedi" git config --global user.email "email@example.com"
Replace name with your git name and email id.