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