Search in sources :

Example 36 with SshException

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

the class Eddsa25519PublicKeyCodec method decode.

@Override
public PublicKey decode(byte[] bytes) {
    try {
        Buffer buf = new Buffer.PlainBuffer(bytes);
        final int keyLen = buf.readUInt32AsInt();
        final byte[] p = new byte[keyLen];
        buf.readRawBytes(p);
        if (logger.isDebugEnabled()) {
            logger.debug("Key algo: {}, Key curve: 25519, Key Len: {}\np: {}", getName(), keyLen, Arrays.toString(p));
        }
        EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName("Ed25519");
        EdDSAPublicKeySpec publicSpec = new EdDSAPublicKeySpec(p, ed25519);
        return new Ed25519PublicKey(publicSpec);
    } catch (Buffer.BufferException be) {
        throw new SshException(be);
    }
}
Also used : Buffer(com.jn.agileway.ssh.client.utils.Buffer) EdDSAPublicKeySpec(net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec) SshException(com.jn.agileway.ssh.client.SshException) EdDSANamedCurveSpec(net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec)

Example 37 with SshException

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

the class JschSessionedChannel method getErrorInputStream.

@Override
public InputStream getErrorInputStream() throws SshException {
    Preconditions.checkState(channel != null);
    if (this.errorInputStream == null) {
        try {
            InputStream errorInputStream = null;
            switch(type) {
                case EXEC:
                    errorInputStream = ((ChannelExec) channel).getErrStream();
                    break;
                case SUBSYSTEM:
                    errorInputStream = ((ChannelSubsystem) channel).getErrStream();
                    break;
                case SHELL:
                    break;
                default:
                    break;
            }
            this.errorInputStream = errorInputStream;
        } catch (Throwable ex) {
            throw new SshException(ex);
        }
    }
    return this.errorInputStream;
}
Also used : InputStream(java.io.InputStream) SshException(com.jn.agileway.ssh.client.SshException)

Example 38 with SshException

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

the class J2sshConnectionFactory method setKnownHosts0.

protected void setKnownHosts0(SshConnection connection, J2sshConnectionConfig sshConfig) {
    String filepath = sshConfig.getKnownHostsPath();
    List<File> files = SshConfigs.getKnownHostsFiles(filepath);
    HostKeyVerification verifier = null;
    if (files.isEmpty()) {
        verifier = new IgnoreHostKeyVerification();
    } else {
        try {
            verifier = new KnownHostsVerifier(files.get(0).getAbsolutePath());
        } catch (Throwable ex) {
            throw new SshException(ex);
        }
    }
    connection.addHostKeyVerifier(new FromJ2ssHostKeyVerifier(verifier));
}
Also used : IgnoreHostKeyVerification(com.sshtools.j2ssh.transport.IgnoreHostKeyVerification) FromJ2ssHostKeyVerifier(com.jn.agileway.ssh.client.impl.j2ssh.verifier.FromJ2ssHostKeyVerifier) HostKeyVerification(com.sshtools.j2ssh.transport.HostKeyVerification) IgnoreHostKeyVerification(com.sshtools.j2ssh.transport.IgnoreHostKeyVerification) SshException(com.jn.agileway.ssh.client.SshException) File(java.io.File) KnownHostsVerifier(com.jn.agileway.ssh.client.impl.j2ssh.verifier.KnownHostsVerifier)

Example 39 with SshException

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

the class SynergySessionedChannel method internalShell.

@Override
protected void internalShell() throws SshException {
    try {
        RequestFuture future = channel.startShell();
        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 40 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.trileadssh2.sftp.Ssh2SftpSession) SFTPv3Client(com.trilead.ssh2.SFTPv3Client) SshException(com.jn.agileway.ssh.client.SshException)

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