sshwrap - Jsch Wrapper

Convenience API to make Jsch easier to use

License

License

GroupId

GroupId

org.commonjava.sshwrap
ArtifactId

ArtifactId

sshwrap
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

jar
Description

Description

sshwrap - Jsch Wrapper
Convenience API to make Jsch easier to use
Source Code Management

Source Code Management

http://github.com/jdcasey/sshwrap

Download sshwrap

How to add to project

<!-- https://jarcasting.com/artifacts/org.commonjava.sshwrap/sshwrap/ -->
<dependency>
    <groupId>org.commonjava.sshwrap</groupId>
    <artifactId>sshwrap</artifactId>
    <version>0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.commonjava.sshwrap/sshwrap/
implementation 'org.commonjava.sshwrap:sshwrap:0.2'
// https://jarcasting.com/artifacts/org.commonjava.sshwrap/sshwrap/
implementation ("org.commonjava.sshwrap:sshwrap:0.2")
'org.commonjava.sshwrap:sshwrap:jar:0.2'
<dependency org="org.commonjava.sshwrap" name="sshwrap" rev="0.2">
  <artifact name="sshwrap" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.commonjava.sshwrap', module='sshwrap', version='0.2')
)
libraryDependencies += "org.commonjava.sshwrap" % "sshwrap" % "0.2"
[org.commonjava.sshwrap/sshwrap "0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
log4j : log4j jar 1.2.12
com.jcraft : jsch jar 0.1.42
commons-lang : commons-lang jar 2.5
commons-io : commons-io jar 1.4

test (1)

Group / Artifact Type Version
junit : junit jar 4.8.1

Project Modules

There are no modules declared in this project.

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;
}

Versions

Version
0.2