0

git clone https://username:password@github.com/xyz-abc/RUBIKS-CUBE-SOLVER.git

trying to write shell script to clone git repository but have to pass my username and password direct

so is there any alternative or secure or encrypted way where in i can hide my username and password from other and clone the repository.

i am on Debian 6.

umläute
  • 28,885
  • 9
  • 68
  • 122
mOsEs
  • 131
  • 2
  • 9
  • why do you need to provide username/password at all, when cloning a github-repository via `https://`? here i'm allowed to clone without authentication (only when i push to the repository, i have to authenticate). or is this a *private* repository? – umläute Feb 11 '14 at 13:37
  • yes its a private repo @umläute – mOsEs Feb 12 '14 at 05:01
  • i am trying to write a shell script with following command in it https://username:password@github.com/xyz-abc/RUBIKS-CUBE-SOLVER.git – mOsEs Feb 12 '14 at 13:05
  • the main thing this shell script is the first thing to happen after the operating system installation – mOsEs Feb 13 '14 at 06:06

2 Answers2

1

use the ssh-access to github:

 git clone git+ssh://git@github.com/xyz-abc/RUBIKS-CUBE-SOLVER.git

and use certificates for authentification

umläute
  • 28,885
  • 9
  • 68
  • 122
  • how can i achieve it in within a shell script.... actually i want to write a shell script which well clone all repo on its execution but don't want to expose my password for the one who opens my shell script – mOsEs Feb 12 '14 at 05:04
  • simply put it in the shell-script... i don't fully understand your question (or rather: problem) – umläute Feb 12 '14 at 09:32
  • i am trying to write a shell script with following command in it https://username:password@github.com/xyz-abc/RUBIKS-CUBE-SOLVER.git and when every of the client m\c on lan runs it daily they will get this fresh clone copy.... but if client on lan they open the shell script and have a look they can see the git-hub password in url and i don't want that to happen – mOsEs Feb 12 '14 at 13:10
  • https://help.github.com/articles/generating-ssh-keys ....i tried it but the main problem with my shell script is it is startup shell shell script for setting up work environment for new user...can i do something like other can run my shell script and they will get the repo but will not get my password..... the main thing this shell script is the first thing to happen after the operating system installation – mOsEs Feb 13 '14 at 06:02
0

If you're using git > 1.8.3 you can use an gpg encrypted .netrc to store your password. You can find a guide here.

If you're using git with a version < 1.8.3 you can store the passwords in a file but only in plain text. If you're using linux you can write a .netrc file and make it readable only by the user.

Your .netrc should contain:

machine myRemoteServer
login myUserName
password s3cret

Make it readable only by the user:

 chmod 600 .netrc
Community
  • 1
  • 1
Atropo
  • 12,231
  • 6
  • 49
  • 62
  • as i am writing the shell script i have to give the password to it and the user can easily see the password.. – mOsEs Feb 13 '14 at 06:04