Here is a bit of a check list:
- Is ssh enabled on the server you are trying to connect to?
- Is GIT installed on the server?
- Do you have a Git repository set-up on the server?
- Does the repository the correct permissions and have sharedrepository enabled in the config on the server?
Do you have the ssh keys in the right place for GIT?
Suggestions:
1: Since you can connect using putty, looks like ssh is setup ok.
2: Use putty and connect to the server. Type in git --version
Do you get back a reasonable response? If not then you will need to install it on the server.
3:Try setting up a new repository on the server. Assuming its a *nix style server use putty and connect to the server and make a new repository using the following commands, assuming you have a directory /home/source_code. The echo line just makes a file with a little bit of text in it so we have something to start with.
cd /home/source_code
mkdir test_repo
cd /home/source_code/test_repo
echo "first file" > t.txt
git init
git add .
git commit -m "Initial Import"
So now we have a repository with one t.txt file in it. As a rule you should never push into a repository that contains changes to the working copy. The purpose of having a repository on the server is so that people can push into it all the time. We make a "bare" clone which is only the git database, that way there is no possibility of any working copy changes. It is this "bare" clone that we will use as the central git repository.
cd /home/source_code
git clone --bare test_repo/ test_repo.git
You can now get rid of the temporary repository that we set up.
cd /home/source_code/
rm -rf test_repo
On your local computer try cloning again
git clone ssh://[email protected]:port/home/source_code/test_repo.git
4: Permissions: This should not cause a problem with cloning, fetching or pulling, unless you have selected a location for the repository that doesnt have read access. If you get a Permission denied error when pushing back then refer to Permissions correction
5: Setting up public/private key for GIT:
- Connect to the server with putty
- Set permissions on your ~/.ssh folder:
chmod 700 .ssh
- Set permissions on your ~/.ssh/authorized_keys:
chmod 600 authorized_keys
- Generate the keys
ssh-keygen -t dsa
- Accept the file names it wants to use
- Don't enter a passphrase (just enter). You will want to redo do this with a passphrase later.
- add the pub key to the authorized_keys file:
cat id_dsa.pub >> .ssh/authorized_keys
- edit /etc/ssh/ssh_config and add the line
PubkeyAuthentication yes
- restart the ssh daemon
sudo /etc/init.d/ssh restart
- Copy
id_dsa
and id_dsa.pub
from the server to your local hard drive (use winscp or sftp or some such tool) c:\users\userName\.ssh directory (this is for vista the location will be a bit different for other versions of windows)
- Set tortoise git to point to C:\Program Files\Git\bin\ssh.exe (not putty)
Both the command line git and tortoise git should be setup to work. Try cloning again on your local machine.
git clone ssh://[email protected]:port/home/source_code/test_repo.git
You might now want to go and repeat setting up the keys with a passphrase....