1

I'm doing this and it works fine but I'd like to be able to hit an sshd on a port other than 22.

 final SSHClient ssh = new SSHClient();
 ssh.addHostKeyVerifier( SFTP_KEY_FINGERPRINT );

 ssh.connect( SFTP_SERVER_HOSTNAME );
 try {
     ssh.authPassword( SFTP_USER ,  SFTP_PASSWORD );
     final String src = fileToFtp.getFileName().toString();
     final SFTPClient sftp = ssh.newSFTPClient();
     try {
          sftp.put(new FileSystemFile(src), "/");
          success = true;
     } finally {
          sftp.close();
     }
   } finally {
     ssh.disconnect();
   }
denniskbijo
  • 576
  • 3
  • 10
Andrew
  • 1,031
  • 10
  • 24

1 Answers1

2

There's an overloaded version of ssh.connect():

ssh.connect(String hostname, int port)

If you use this version, you can specify the port you want to connect on.

Dave Birch
  • 469
  • 4
  • 10