Question

I am working on my raspberry pi server and whenever I clone or do anything on the gitremotely I want to disable password on the push and pull. How do I do that? I don't want to enter password on git shell when I try to pull or push any changes to the server.

Était-ce utile?

La solution 2

You need to generate your SSH keys (like @Ajedi32 exlains) or like is explained on github page : https://help.github.com/articles/generating-ssh-keys

Also currently if you type git remote -v you will see that your repository (origin probably) will have pathes starting with https://github.com/user/repo.git). This means that git on your local machine is referring to remote git repo via https. When referring to the remote git repo via https, git will ALWAYS ask for password.

This is why AFTER you have set up the SSH keys as described in one of the methods above, you must change the way git is referring to the remote repo from https protocol to ssh protocol.

To do that you first have to write down you current repo path, eg. https://github.com/username/reponame.git then you can convert it to the ssh style address: ssh://git@github.com/username/reponame.git (mind that you only have to change username and reponame parts. Leave git@github.com as it is. It always must be like this.

Then on your local machine you can type the following code: If you're on linux

git remote -v
git remote rm origin
git remote add origin ssh://git@github.com/username/reponame.git
git remote -v 

The last command will print you the path via which git refers to the remote repository and it will be starting with ssh://....

Mind that when using command git remote -v the repository path will be printed twice, once for fetch and once with push comment.

Autres conseils

I'm not certain what your exact set up is, but it sounds to me like you want to set up an SSH key on your server. The Pro Git book covers how to do this quite thoroughly in Chapter 4.4:

Let’s walk through setting up SSH access on the server side. In this example, you’ll use the authorized_keys method for authenticating your users. We also assume you’re running a standard Linux distribution like Ubuntu. First, you create a 'git' user and a .ssh directory for that user.

$ sudo adduser git
$ su git
$ cd
$ mkdir .ssh

Next, you need to add some developer SSH public keys to the authorized_keys file for that user. Let’s assume you’ve received a few keys by e-mail and saved them to temporary files. Again, the public keys look something like this:

$ cat /tmp/id_rsa.john.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCB007n/ww+ouN4gSLKssMxXnBOvf9LGt4L
ojG6rs6hPB09j9R/T17/x4lhJA0F3FR1rP6kYBRsWj2aThGw6HXLm9/5zytK6Ztg3RPKK+4k
Yjh6541NYsnEAZuXz0jTTyAUfrtU3Z5E003C4oxOj6H0rfIF1kKI9MAQLMdpGW1GYEIgS9Ez
Sdfd8AcCIicTDWbqLAcU4UpkaX8KyGlLwsNuuGztobF8m72ALC/nLF6JLtPofwFBlgc+myiv
O7TCUSBdLQlgMVOFq1I2uPWQOkOWQAHukEOmfjy2jctxSDBQ220ymjaNsHT4kgtZg2AYYgPq
dAv8JggJICUvax2T9va5 gsg-keypair

You just append them to your authorized_keys file:

$ cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.josie.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.jessica.pub >> ~/.ssh/authorized_keys
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top