Search in sources :

Example 11 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class SynergySessionedChannel method env.

@Override
public void env(String variableName, String variableValue) throws SshException {
    try {
        RequestFuture future = channel.setEnvironmentVariable(variableName, variableValue);
        future.waitForever();
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : RequestFuture(com.sshtools.common.ssh.RequestFuture) SshException(com.jn.agileway.ssh.client.SshException)

Example 12 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class SynergySessionedChannel method internalSubsystem.

@Override
protected void internalSubsystem(String subsystem) throws SshException {
    try {
        RequestFuture future = channel.startSubsystem(subsystem);
        future.waitForever();
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : RequestFuture(com.sshtools.common.ssh.RequestFuture) SshException(com.jn.agileway.ssh.client.SshException)

Example 13 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class Ssh2Connection method openSftpSession.

@Override
public SftpSession openSftpSession() throws SshException {
    try {
        SFTPv3Client sftpClient = new SFTPv3Client(this.delegate);
        Ssh2SftpSession session = new Ssh2SftpSession(sftpClient);
        session.setSshConnection(this);
        return session;
    } catch (Throwable ex) {
        throw new SshException(ex.getMessage(), ex);
    }
}
Also used : Ssh2SftpSession(com.jn.agileway.ssh.client.impl.ganymedssh2.sftp.Ssh2SftpSession) SFTPv3Client(ch.ethz.ssh2.SFTPv3Client) SshException(com.jn.agileway.ssh.client.SshException)

Example 14 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class Ssh2Connection method openSession.

@Override
public SessionedChannel openSession() throws SshException {
    Preconditions.checkNotNull(delegate);
    Preconditions.checkState(getStatus() == SshConnectionStatus.CONNECTED, "ssh not connected");
    try {
        Session session = delegate.openSession();
        Ssh2SessionedChannel channel = new Ssh2SessionedChannel(session);
        return channel;
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : SshException(com.jn.agileway.ssh.client.SshException) SftpSession(com.jn.agileway.ssh.client.sftp.SftpSession) Session(ch.ethz.ssh2.Session) Ssh2SftpSession(com.jn.agileway.ssh.client.impl.ganymedssh2.sftp.Ssh2SftpSession)

Example 15 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class Ssh2Connection method connect.

@Override
public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SshException {
    try {
        if (delegate == null) {
            Socket localSocket = null;
            if (localAddr != null && Nets.isValidPort(localPort)) {
                localSocket = new Socket(localAddr, localPort);
            }
            Connection conn = new Connection(host.getHostName(), port, localSocket);
            if (this.hostKeyVerifier.isEmpty()) {
                conn.connect();
            } else {
                conn.connect(new ToSsh2HostKeyVerifierAdapter(this.hostKeyVerifier));
            }
            setStatus(SshConnectionStatus.CONNECTED);
            this.delegate = conn;
        }
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : ToSsh2HostKeyVerifierAdapter(com.jn.agileway.ssh.client.impl.ganymedssh2.verifier.ToSsh2HostKeyVerifierAdapter) AbstractSshConnection(com.jn.agileway.ssh.client.AbstractSshConnection) Connection(ch.ethz.ssh2.Connection) SshException(com.jn.agileway.ssh.client.SshException) Socket(java.net.Socket)

Aggregations

SshException (com.jn.agileway.ssh.client.SshException)40 ForwardingChannelInfo (com.jn.agileway.ssh.client.channel.forwarding.ForwardingChannelInfo)7 RequestFuture (com.sshtools.common.ssh.RequestFuture)4 SshClient (com.sshtools.j2ssh.SshClient)4 Connection (com.trilead.ssh2.Connection)3 InetSocketAddress (java.net.InetSocketAddress)3 SSHClient (net.schmizz.sshj.SSHClient)3 AbstractSshConnection (com.jn.agileway.ssh.client.AbstractSshConnection)2 Ssh2SftpSession (com.jn.agileway.ssh.client.impl.ganymedssh2.sftp.Ssh2SftpSession)2 ToSynergyHostKeyVerifierAdapter (com.jn.agileway.ssh.client.impl.synergy.verifier.ToSynergyHostKeyVerifierAdapter)2 Ssh2SftpSession (com.jn.agileway.ssh.client.impl.trileadssh2.sftp.Ssh2SftpSession)2 SftpSession (com.jn.agileway.ssh.client.sftp.SftpSession)2 SshClient (com.sshtools.client.SshClient)2 SshClientContext (com.sshtools.client.SshClientContext)2 RemotePortForwarder (net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder)2 Connection (ch.ethz.ssh2.Connection)1 LocalPortForwarder (ch.ethz.ssh2.LocalPortForwarder)1 SFTPv3Client (ch.ethz.ssh2.SFTPv3Client)1 Session (ch.ethz.ssh2.Session)1 ChannelSftp (com.jcraft.jsch.ChannelSftp)1