0

Wondering if anyone can help with a Git push setup I'm having trouble with? I am trying to setup Git remote on a Windows local computer and push to a IONOS shared host server. I am able to SSH to my IONOS shared host using PuTTY with no issues. So I'm hoping I can setup Git to remote to the server and push local update files to the host repo. Here's what I've tried so far:

When I PuTTY into the host server using username, ip address, I land here:

(uiserver):u123:~$

ls produces this

logs  repo  src  www

My post-receive file in repo/site.git/hooks =

#!/bin/sh
git --work-tree=/ --git-dir=/repo/site.git checkout -f  

local git remote setup =

git remote add production ssh://u123@<ip address>:22/repo/site.git (u123 is user name, I do not have root access)

When I do a "git push production master" from a Git Bash (MINGW64) cmd window, I get the stock "The server's host key is not cached in the registry ... " stuff, answer "n" (until I get it working) and it just hangs. I then Ctrl-C and I get "fatal: Could not read from remote repository".

repo dirs on host server are rwx on all for now, until (if) I get this working, so I know I have full access. I do have full path info on the host server and have also tried those in the post-receive and git remote.

Like I mentioned, username and ip address work in PuTTY, just not via Git. Any help would be appreciated, I've exhausted every combo I can think of. Maybe I just cannot do this on a IONOS Hosted Server.

tia _mark

mdRafn
  • 3
  • 2
  • Can you ssh to u123@ from git bash `ssh -vvv u123@` ? Git bash has no link with putty, so you may be able to connect through putty but doesn't mean it would work through git bash. Could you not truncate the message you get and even better paste the full output of the git bash session? – zigarn Mar 04 '21 at 00:18
  • yes -- just tried to connect via git bash and it worked fine. I will try to setup git remote again. It must be a destination or post-recieve problem I'm assuming. – mdRafn Mar 05 '21 at 13:02
  • Interesting ... I can ssh to the server from git bash and login ok, but when I try using git with remote set to the same ssh, I get: $ git push --dry-run production master fatal: protocol error: bad line length character: u814 (that's my actual username truncated by 5 chars) – mdRafn Mar 05 '21 at 13:42
  • Have you any special git config? (in `.git/config` or in `~/.gitconfig`) – zigarn Mar 05 '21 at 13:57
  • nope - no special git config that I can see. so here is the actual git remote add setup (with numbers changed but total string length the same). git remote add ssh://u81411111@home581234567.1and1-data.host/repo/site.git - then git push production master produces - fatal: protocol error: bad line length character: u814 Stumped, but I'm not a Git expert :) – mdRafn Mar 05 '21 at 23:07
  • You can look at https://stackoverflow.com/questions/8170436/git-remote-error-fatal-protocol-error-bad-line-length-character-unab for solutions to try (did you search your error message in the first place?) – zigarn Mar 06 '21 at 05:07
  • Does the u123 user has permission on `/`? Because your post-receive hook on the remote is trying to checkout the repository in `/`. What happens if you try to execute the command from your post-receive hook when you're connected on the remote with the u123 user? – zigarn Mar 06 '21 at 05:12
  • Ok -- I ~think I've fixed the post-receive by changing to the correct dir from /. Trying the command now from post-receive gives "fatal: You are on a branch yet to be born" which seems right because nothing has been pushed yet. I have looked at the suggested stackoverflow, I have searched plenty for this error. It seems like it is echoing back the beginning of the ssh login asking for password per the suggestions, but unsure how to fix. thanks for your help on this – mdRafn Mar 06 '21 at 19:36
  • It has something to do with prompting for a password, which is needed on this host. It does not come back with an "enter password", just the line length error. On a different account (VPS), where I have root control, I've set it up to use an ssh key so no password is required and it works fine. Trying to setup an ssh key on this shared host, but that's another story ... – mdRafn Mar 06 '21 at 21:35
  • Git should handle the ssh login without any issue. Looks more like the ssh session is answering back a text when it should answer a kind of "git packet". What if you remove the post-receive hook? – zigarn Mar 06 '21 at 21:57
  • Can you give the full output of the `ssh u123@ pwd`? – zigarn Mar 07 '21 at 02:48
  • Good news, I've got the Git push working. Solution is to get the shared host login using an ssh key. So you're probably right in that the ssh session is answering with a prompt for a password which Git is choking on. By logging in with the ssh key, Git proceeds as it should -- all is well now. Thanks much with all your help, it helped in digging down to a solution. – mdRafn Mar 07 '21 at 15:50

0 Answers0