Transport through an SSH tunnel. The SSH transport requires the remote side to have Git installed, as the transport logs into the remote system and executes a Git helper program on the remote side to read (or write) the remote repository's files. This transport does not support direct SCP style of copying files, as it assumes there are Git specific smarts on the remote side to perform object enumeration, save file modification and hook execution.
Inheritance: SshTransport, IPackTransport, IDisposable
        /// <summary>
        /// Open a new transport instance to connect two repositories.
        /// </summary>
        /// <param name="local">existing local repository.</param>
        /// <param name="remote">location of the remote repository.</param>
        /// <returns>the new transport instance. Never null.</returns>
        public static Transport open(Repository local, URIish remote)
        {
            if (TransportGitSsh.canHandle(remote))
            {
                return(new TransportGitSsh(local, remote));
            }

            if (TransportHttp.canHandle(remote))
            {
                return(new TransportHttp(local, remote));
            }

            if (TransportSftp.canHandle(remote))
            {
                return(new TransportSftp(local, remote));
            }

            if (TransportGitAnon.canHandle(remote))
            {
                return(new TransportGitAnon(local, remote));
            }

            if (TransportAmazonS3.canHandle(remote))
            {
                return(new TransportAmazonS3(local, remote));
            }

            if (TransportBundleFile.canHandle(remote))
            {
                return(new TransportBundleFile(local, remote));
            }

            if (TransportLocal.canHandle(remote))
            {
                return(new TransportLocal(local, remote));
            }

            throw new NotSupportedException("URI not supported: " + remote);
        }
            public SshPushConnection(TransportGitSsh instance)
                : base(instance)
            {
                try
                {
                    _channel = instance.Exec(instance.OptionReceivePack);

                    if (_channel.isConnected())
                    {
                        init(_channel.getInputStream(), _channel.getOutputStream());
                    }
                    else
                    {
                        throw new TransportException(uri, instance._errStream.ToString());
                    }
                }
                catch (TransportException)
                {
                    Close();
                    throw;
                }
                catch (SocketException err)
                {
                    Close();
                    throw new TransportException(uri, "remote hung up unexpectedly", err);
                }

                try
                {
                    readAdvertisedRefs();
                }
                catch (NoRemoteRepositoryException notFound)
                {
                    Close();
                    instance.checkExecFailure(_exitStatus, instance.OptionReceivePack);
                    throw instance.cleanNotFound(notFound);
                }
            }
Exemple #3
0
            public SshPushConnection(TransportGitSsh instance)
                : base(instance)
            {
                try
                {
                    _channel = instance.Exec(instance.OptionReceivePack);

                    if (_channel.isConnected())
                    {
                        init(_channel.getOutputStream());
                    }
                    else
                    {
                        throw new TransportException(uri, instance._errStream.ToString());
                    }
                }
                catch (TransportException)
                {
                    Close();
                    throw;
                }
                catch (SocketException err)
                {
                    Close();
                    throw new TransportException(uri, "remote hung up unexpectedly", err);
                }

                try
                {
                    readAdvertisedRefs();
                }
                catch (NoRemoteRepositoryException notFound)
                {
                    throw instance.cleanNotFound(notFound);
                }
            }
            public SshFetchConnection(TransportGitSsh instance)
                : base(instance)
            {
                try
                {
                    _channel = instance.Exec(instance.OptionUploadPack);

                    if (_channel.isConnected())
                        init(_channel.getInputStream(), _channel.getOutputStream());
                    else
                        throw new TransportException(uri, instance._errStream.ToString());
                }
                catch (TransportException)
                {
                    Close();
                    throw;
                }
                catch (SocketException err)
                {
                    Close();
                    throw new TransportException(uri, "remote hung up unexpectedly", err);
                }

                try
                {
                    readAdvertisedRefs();
                }
                catch (NoRemoteRepositoryException notFound)
                {
                    Close();
                    instance.checkExecFailure(_exitStatus, instance.OptionUploadPack);
                    throw instance.cleanNotFound(notFound);
                }
            }