Skip to content

Latest commit

 

History

History
131 lines (103 loc) · 4.08 KB

File metadata and controls

131 lines (103 loc) · 4.08 KB

Quick Start Guide - Enhanced Java SFTP Client for Tectia Server

Problem Summary

Your original SFTP client using j2ssh-maverick-1.5.5.jar couldn't connect to Tectia SSH Server due to incompatible cipher algorithms. Tectia requires modern AEAD ciphers like:

  • aes256-gcm@openssh.com
  • aes128-gcm@openssh.com
  • AEAD_AES_128_GCM
  • AEAD_AES_256_GCM

Solution

This enhanced SFTP client supports modern ciphers and provides three implementation options:

1. 🚀 Enhanced SFTP Client (Recommended)

File: EnhancedSftpClient.java

  • Uses SSHJ library with full AEAD cipher support
  • Best compatibility with Tectia SSH Server
  • Modern SSH protocol implementation

2. 🔄 JSch SFTP Client (Alternative)

File: JSchSftpClient.java

  • Uses JSch library as alternative
  • Good compatibility and lightweight
  • Fallback option if SSHJ has issues

3. 🔧 Compatibility Wrapper (Easy Migration)

File: FtpClientConn.java

  • Maintains your original API
  • Drop-in replacement for existing code
  • Uses enhanced client underneath

Quick Setup

Step 1: Update Your Configuration

Hashtable<String, String> config = new Hashtable<String, String>();
config.put("host", "10.103.3.102");      // Your Tectia server
config.put("port", "22");                 
config.put("username", "FTPDCOSMY");      

// Choose authentication method:
config.put("password", "your_encrypted_password");
// OR
config.put("privatekey", "/path/to/your/private/key");

Step 2: Replace Your Current Code

Option A: Minimal Changes (Recommended)

// Replace this line:
// FtpClientConn.setConfigs(config);
// FtpClientConn client = FtpClientConn.getInstance();

// With this:
EnhancedSftpClient.setConfigs(config);
EnhancedSftpClient client = EnhancedSftpClient.getInstance();

// Use SFTP operations:
SFTPClient sftp = client.getSftpClient();
if (sftp != null) {
    // Your existing SFTP operations
    for (RemoteResourceInfo file : sftp.ls(".")) {
        System.out.println("File: " + file.getName());
    }
}

// Don't forget to disconnect
EnhancedSftpClient.disconnect();

Option B: Use Compatibility Wrapper (No Code Changes)

// Keep your existing code exactly the same!
FtpClientConn.setConfigs(config);
FtpClientConn client = FtpClientConn.getInstance();

// Now uses enhanced client underneath
if (client.isConnected()) {
    // Your existing SFTP operations work
    SFTPClient sftp = client.getEnhancedSftpClient();
    // ... rest of your code
}

Step 3: Replace JAR File

  1. Remove: j2ssh-maverick-1.5.5.jar
  2. Add: java-sftp-client-1.0.0-jar-with-dependencies.jar

Testing Your Connection

Run the provided test class:

java -cp target/java-sftp-client-1.0.0-jar-with-dependencies.jar my.com.eprotea.ftp.TectiaSftpTest

Update the test with your actual credentials before running.

Key Benefits

Tectia Compatible: Supports all required AEAD ciphers
Modern Security: Latest SSH protocol implementations
Easy Migration: Minimal code changes required
Multiple Options: Choose the best fit for your needs
Better Debugging: Enhanced logging for troubleshooting
Production Ready: Proper error handling and connection management

Troubleshooting

Connection Issues

  • Verify server IP, port, and credentials
  • Check firewall settings
  • Enable debug logging to see cipher negotiation

Authentication Issues

  • Verify your Encryptor.decrypt() method works correctly
  • Check private key file path and permissions
  • Ensure username is correct

Cipher Issues

  • Check server logs to see which ciphers are being offered
  • The client automatically negotiates the best available cipher
  • Modern AEAD ciphers will be preferred for Tectia

Next Steps

  1. Test Connection: Use TectiaSftpTest.java with your credentials
  2. Update Code: Choose your preferred implementation approach
  3. Deploy: Replace the old JAR with the new one
  4. Monitor: Check logs to confirm AEAD cipher negotiation

Note: Remember to update the Encryptor class with your actual encryption/decryption logic.