“Access denied” when pushing to remote repository via SSH

I am a newbie with Git and seem to have a problem with pushing to a repository over a network.
Here is what I do to recreate the problem:

  1. create a new Git repository on the computer to push to

  2. What is the difference between a tree and a directory?
  3. Replicate Gated check-in functionality in Visual Studio + VSO + Git
  4. How to push a file to past time?
  5. github: PGP key usage flags do not allow signing
  6. git show <commit> --oneline not showing oneline
  7. Running git diff-tree with --numstat and --name-status
  8. mkdir ~/git/test.git
    cd !$
    git --bare init
    
  9. On my local computer I then create a new Git repository and add a random file to it:

    mkdir test
    git init
    touch TEST
    git add .
    git commit -m "initial commit"
    
  10. Then add the remote computer via: git remote add origin ssh://user@site.com/~/git/test.git

  11. Then I try to push the local repository to the remote via: git push origin master

This is what I get when I do that:

fatal: protocol error: bad line length character  <- sometimes not there
Access denied
Access denied
Access denied
Access denied
FATAL ERROR: Server sent disconnect message
type 2 (protocol error):
"Too many authentication failures for user"

I am using cygwin on an XP machine and trying to push to a unix server.

I have also tried it between my two computers I have at home and I have the same problem, both are windows machines by the way.

I have set up passwordless login via SSH and I can ssh no problem via: ssh user@site.com

I’ve been trying to figure this out for two days now, any help would be appreciated

  • Git pull contents of a folder from a repository
  • Efficient way to get all commits on a given day *and* their branch using Github API
  • Cloning the same repository multiple times with Github for Windows
  • Git is not ignoring neither checking out .vs folder (VS2015)
  • Error Killed: 9 after command “git add .”
  • Having a hard time understanding git-fetch
  • 6 Solutions collect form web for ““Access denied” when pushing to remote repository via SSH”

    The issue is probably that ~ won’t expand correctly when using it in a ssh URI. You would need to specify the absolute path to the git repository on the remote machine in the ssh URI, like this:

    ssh://user@site.com/home/user/git/test.git

    I was having a similar issue, but the solution turned out a little different for my situation. The error message I was getting was:

    $> git push -v unfuddle master
    Pushing to git@subdomain.unfuddle.com:subdomain/repo.git
    Received disconnect from 174.129.246.239: 2: Too many authentication failures for git
    fatal: The remote end hung up unexpectedly
    

    I couldn’t figure out what the problem was, ssh -vv didn’t show anything either. I already had this text in my ~/.ssh/config

    Host subdomain.unfuddle.com
        User git
        IdentityFile ~/.ssh/unfuddle-subdomain-key
    

    The issue turned out to be that Unfuddle’s SSH server is configured to deny access after a certain number of SSH keys are tried. Even though I had a specific IdentityFile set my SSH client was, for unknown reasons, trying all of my local SSH keys in sequence until Unfuddle denied access. The solution was to set the SSH “IdentitiesOnly” config option to “yes” which tell the local SSH client to only send just that one IdentityFile and no others.

    # The fixed ~/.ssh/config line
    Host subdomain.unfuddle.com
        User git
        IdentitiesOnly yes
        IdentityFile ~/.ssh/unfuddle-subdomain-key
    

    Ref: http://railspikes.com/2010/2/1/fixing-the-heroku-too-many-authentication-failures-for-git-problem

    Hopefully this helps someone.

    James

    I’m not sure about your access problems, but the path in

    git remote add origin ssh://user@site.com/~/git/test.git
    

    worries me. What do you get with

    git remote add origin ssh://user@site.com/git/test.git
    

    ?

    Also please show output from git push -v ...

    Try to use

    ssh://user@site.com:/home/user/git/test.git
    

    In your case the problem is probably the ~ character. Use:

      git remote add origin user@site.com/git/test.git
    

    However, I’ve also seen this problem (always on Windows client machines) when the username (“user@”) part was missing, so anyone else with this problem should check that too.

    One more key to solve such a problem. In our case the reason was gitolite.conf file with repositiories and permissions. Someone have edited it with Windows Notepad which added BOM header to it. After this repositiory had very weird behavior when some users could but some could not write to it getting access denied messages.

    Git Baby is a git and github fan, let's start git clone.