Reputation: 4622
I've just initialized a GIT repo in an existing website root. I have a local development copy of this site, which is already a GIT repo. I can't just clone one from the other, as the local/live versions have fallen out of sync over the years.
I'm trying to get them lined back up with GIT again, but I want to be able to do a fetch on the live site and run git diff
My problem is, on the local site I've added the live site as a remote repo:
git remote add live [email protected]:/path/to/repo
I can successfully log in via ssh to my server:
ssh [email protected]
But when I try to fetch, and type in the ssh password, the command line just returns the password prompt, as if I've typed it wrong. But I know the password is correct, as I can use SSH to log in.
Do I have to specify ssh:// before my remote URL? Is there something I have to do to get ssh remote repos working
UPDATE
I've added the ssh:// prefix, but it's made no difference. This is how it looks in .git/config
[remote "live"]
url = ssh://[email protected]/path/to/repo
fetch = +refs/heads/*:refs/remotes/live/*
Running GIT_TRACE=true git fetch live adds in the lines:
trace: run_command 'ssh' '[email protected]' 'git-upload-pack '\''/path/to/repo'\'''
I have to type the password in 3 times before I get the message:
fatal: the remote end hung up unexpectedly
Upvotes: 2
Views: 4817
Reputation: 4128
I think you're missing an alias for the remote.
git remote add origin [email protected]:/path/to/repo
Note the origin
bit.
Is the .git/config you posted accurate? If it is, try changing the remote url from
url = ssh://[email protected]/path/to/repo
to
url = [email protected]:/path/to/repo
Note the :
separating the server name from the server path.
Upvotes: 2
Reputation: 21363
Following only applys if you have shell access to the server. Probably not what you want but incase you want to try set up a public/private key auth. Simply generate a RSA keypair with command :
ssh-keygen -t rsa
I would reccomend you to use a passphrase since you can store it in ssh-agent
after generating a keypair copy the public key over to your server you can use scp :
scp -p ~/.ssh/id_rsa.pub host:~/.ssh/
and then in server do cat id_rsa.pub >> authorized_keys
Upvotes: 0
Reputation: 4423
yes, you need ssh://. Just change it in .git/config file:
url = ssh://[email protected]:/path/to/repo
Upvotes: 0