user892134
user892134

Reputation: 3214

Cloning a repo keeps asking for password

I've been given the task to clone a repository that is located at [email protected]:project.git. I've got the VPS IP address, VPS password and public key myrepo.pub so i can access the repository. This is all the information i have and have been told is all i need.

I've downloaded GitHub for windows and put the public key myrepo.pub into the .ssh folder. I've created a config file in the .ssh folder which looks like below.

host [email protected]
 HostName [email protected]
 IdentityFile ~/.ssh/myrepo.pub
 User root

Now when i open GIT and attempt to clone git clone [email protected]:project.git, i get asked for a password. I've been told:

"If everything is set right - no authorization (password) will be required as server authorizes you with your public key. This public key is your marker."

How do i solve this? Is it my config file? This is my first time using GIT, any help greatly appreciated.

Upvotes: 1

Views: 6344

Answers (1)

Stefan Marinov
Stefan Marinov

Reputation: 581

You actually need your private key in your local .ssh folder. The public key goes in the server's .ssh/authorized_keys. The idea is that in order to authorize yourself you absolutely need your private key, but the people/servers/programs you authorize to need only your public key.

Also, your configuration is somewhat confusing. You may want something like:

Host myserver
    User git
    HostName xx.xxx.xxx.xx
    PubkeyAuthentication yes
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/myrepo

Then you can clone the repository with git clone myserver:project.git <target_directory>. If <target_directory> isn't provided by either a relative or an absolute path, git usually tries to clone into ./project/. It may give you errors if the folder already exists and is not empty.

Whether you need to enter a password depends only on whether you set your private key with such or not.

A few notes on the configuration:

  • The git@ part of the address is the user on the server which you need to enter here.
  • The two additional lines may not be necessary, but it's good practice to include them.
  • You can read the appropriate man page for more information on all possible options in this file: man ssh_config.

Upvotes: 4

Related Questions