Skip to content
Convenience API for Jsch
Java
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src/main/java/org/commonjava/sshwrap
LICENSE.txt
README.markdown
pom.xml

README.markdown

SSHWrap - Convenience API for Jsch

SSHWrap is designed to provide a minimal set of classes that allow you streamlined access to the features of the Jsch Java SSH client library.

Usage

Imagine that you need to create and initialize a bare remote Git repository for a project you're about to push. The following method will do the trick:

private boolean createRemoteGitRepo( final String dir )
    throws IOException, SSHWrapException
{
    SSHConnection ssh = new SSHConnection( USER, HOST, PORT ).connect();

    final Set<String> cmds = new HashSet<String>();
    cmds.add( "mkdir -p " + dir );
    cmds.add( "git --git-dir=" + dir + " --bare init" );

    final ByteArrayOutputStream cmdOutput = new ByteArrayOutputStream();

    for ( final String cmd : cmds )
    {
        cmdOutput.reset();
        final int result = ssh.execute( cmd, cmdOutput );

        if ( LOGGER.isDebugEnabled() )
        {
            LOGGER.debug( new String( cmdOutput.toByteArray() ) );
        }

        if ( result != 0 )
        {
            return false;
        }
    }

    return true;
}
Something went wrong with that request. Please try again.