使用git与apache sshd

我试图在我使用sshd用Java编写的SSH服务器上使用msysgit,我已经取得了很大的进步,我遇到了一些git错误,我能够使用putty进行连接并得到一个shell,我在我的窗口中有git路径,但我仍然无法使用git通过我的ssh守护程序连接到我的存储库。 我从msysgit收到以下错误:

 fatal: ''/C/gitrepo'' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

我使用以下内容将遥控器添加到我试图连接的repo:

 git remote set-url origin "ssh://test@localhost:22/C/gitrepo". 

我尝试了许多其他变化以及没有运气的路径。 我在localhost上设置了两个git repos,我正在运行git push和c:\gitrepo

我错过了什么?

此外,我不得不将mysysgit / bin的路径添加到我的windows 7环境变量中,但是还想要一种方法来实现它,而不是将其添加到我的Windows环境变量中,而是在我的ssh服务器中以编程方式指定它,但更重要的是我希望能够在这个ssh服务器上运行git。

我的服务器的代码如下。

 import java.io.IOException; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import org.apache.sshd.SshServer; import org.apache.sshd.server.UserAuth; import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.util.OsUtils; import org.apache.sshd.server.Command; import org.apache.sshd.server.CommandFactory; import org.apache.sshd.server.ForwardingFilter; import org.apache.sshd.server.PasswordAuthenticator; import org.apache.sshd.server.auth.UserAuthPassword; import org.apache.sshd.server.command.ScpCommandFactory; import org.apache.sshd.server.filesystem.NativeFileSystemFactory; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; import org.apache.sshd.server.session.ServerSession; import org.apache.sshd.server.shell.ProcessShellFactory; public class SSHD { public SSHD() { init(); } public void start() throws IOException { sshServer.start(); } private void init() { sshServer = SshServer.setUpDefaultServer(); sshServer.setPort(22); sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); setupAuthentication(); setupCommandHandling(); } private void setupAuthentication() { sshServer.setPasswordAuthenticator(new SSHD.MyPasswordAuthenticator()); List<NamedFactory> userAuthFactories = new ArrayList<NamedFactory>(); userAuthFactories.add(new UserAuthPassword.Factory()); sshServer.setUserAuthFactories(userAuthFactories); } private void setupCommandHandling() { CommandFactory myCommandFactory = new CommandFactory() { @Override public Command createCommand(String command) { System.out.println("command = \"" + command + "\""); return new ProcessShellFactory(command.split(" ")).create(); } }; sshServer.setCommandFactory(new ScpCommandFactory(myCommandFactory)); sshServer.setFileSystemFactory(new NativeFileSystemFactory()); sshServer.setForwardingFilter(new ForwardingFilter() { public boolean canForwardAgent(ServerSession session) { return true; } public boolean canForwardX11(ServerSession session) { return true; } public boolean canListen(InetSocketAddress address, ServerSession session) { return true; } public boolean canConnect(InetSocketAddress address, ServerSession session) { return true; } }); ProcessShellFactory shellFactory = null; if (OsUtils.isUNIX()) { shellFactory = new ProcessShellFactory(new String[]{"/bin/sh", "-i", "-l"}, EnumSet.of(ProcessShellFactory.TtyOptions.ONlCr)); } else { shellFactory = new ProcessShellFactory(new String[]{"cmd.exe "}, EnumSet.of(ProcessShellFactory.TtyOptions.Echo, ProcessShellFactory.TtyOptions.ICrNl, ProcessShellFactory.TtyOptions.ONlCr)); } sshServer.setShellFactory(shellFactory); } private static class MyPasswordAuthenticator implements PasswordAuthenticator { @Override public boolean authenticate(String username, String password, ServerSession session) { return true; } } public static void main(String[] args) { SSHD sshd = new SSHD(); try { sshd.start(); } catch (IOException ex) { System.out.println("EXCEPTION: " + ex); ex.printStackTrace(); } } private SshServer sshServer; } 

有谁知道如何修复服务器端的手动解析。 我可以使用不同的命令处理器或类似的东西吗?