Reputation: 176
I want to add TLS support to my SFTP connection. Currently using JSch to achieve it. But I am not sure how to use it.
private void connection() {
JSch jsch = new JSch();
try {
session = jsch.getSession(username, host, port);
session.setPassword(password);
session.setConfig(MAX_SESSIONS_PROP, MAX_SESSIONS_DEFAULT);
session.setConfig(MAX_STARTUPS_PROP, MAX_STARTUPS_DEFAULT);
session.setTimeout(DEFAULT_TIMEOUT_MS);
session.connect();
channel = session.openChannel(CHANNEL);
channel.connect();
channelSftp = (ChannelSftp) channel;
} catch (JSchException e) {
throw new ConnectException("Can not get connection to SFTP: ", e);
}
}
Please help me out.
Upvotes: 1
Views: 3035
Reputation: 202642
TLS has nothing to do with SFTP.
TLS is used for example to encrypt FTP connections.
SFTP uses SSH for encryption. And you do not need to do anything for it. SFTP is virtually never used without SSH. And JSch does not even allow using SFTP without SSH (the same is true for majority of other SSH clients/libraries).
Upvotes: 3