Monday, September 19, 2016
How to access git using a key pair
This could be usefull when you are using Amazon server with a keypair file without a password otherwise you don't need to follow this guide.
1) Upload/Copy the keypair file (.pem) on your ~/.ssh/ directory
$ cp cert.pem ~/.ssh/.
2) Move on your ssh directory and change the permissions on the file
$ chmod 400 cert.pem
3) Create or update your ~/.ssh/config file
$ nano ~/.ssh/config
4) Copy and update the rows below with the correct hostname, user and identifyfile:
Host git
Hostname www.example.com
User ubuntu
IdentityFile /pathtossh/ssh/cert.pem
5) Clone the repository
$ git clone git:/path/to/remoteproject/repository.git
Done!
If you need to copy and overwrite the entire cloned project inside another directory you could you the command below:
$ \cp -R source destination
To update your projects and use the new address you need to open the project's git config file
$ nano ~/path/to/remoteproject/.git/config
After that you have to change the url line:
git:path/to/remoteproject/repository.git
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment