简体   繁体   中英

Clone a remote Git repo (Server denied you to change to the given directory)

I have a git repo set on a remote server. I'm trying to clone it on my own PC with this command :

git clone ftp://xxxx/testGit/ testGit

But I keep getting the error :

fatal: unable to access ' ftp://xxxx/testGit/ ': Server denied you to change to the given directory

The same URL works fine in my browser, I don't really understand ...

I'm using vsftpd with this config :

listen=YES
anonymous_enable=YES
local_enable=NO
write_enable=NO
local_root=/home/play/

I'm out of ideas ...

You need to run git update-server-info on the server :)

If the repository is non-bare (ie has a .git directory), you also need to append /.git to the path as mentioned by @Rohit Pothuraju .


How do you debug problems like this?

My first attempt was to to get a verbose log out of vsftpd . I read the manual and set the relevant options, but it didn't work (the log was empty).

So I fell back to intercepting the TCP connection. The most primitive way to do that is have three terminal windows running the following commands:

1. nc -v x.x.x.x 21     # connect to the real server
2. nc -l -v -p 1234     # listen on some port
   # if it says "This is nc from the netcat-openbsd package", remove the '-p'
3. git clone ftp://localhost:1234/testGit/ testGit
   # the program you want to debug, but with the server address replaced

Now you'll see messages from the server in Terminal 1 and messages from the program in Terminal 2. When you see a message in one terminal, copy it and paste it into the other terminal. Keep going until the session ends.

Tips:

  • The -v flag causes netcat to print one or two debugging lines. Make sure you don't copy them between the two terminals! In Terminal 1 this should be similar to

     localhost [123.0.01] (?) open 

    and in Terminal 2 it should be similar to

     listening on [any] 1234... connect to [127.0.0.1] from localhost [1237.0.0.1] 53929 
  • With some protocols (such as FTP) the server sends the first message. Don't forget to copy that message over once the program connects, otherwise it will wait forever.

I suggest you try this..

git clone ftp://username:password@ftp.company.com:PORT/project.repo/.git

It might work....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM