0
当我们需要将公钥添加到授权密钥时,为什么我们使用私钥进行身份文件验证sftp传输当我们需要将公钥添加到授权密钥时,为什么我们需要将私钥用作身份文件进行SFTP传输使用JSch
Session session = null;
ChannelSftp sftpChannel = null;
JSch jsch = new JSch();
try
{
session = jsch.getSession(targetUserId, targetHost, targetPort);
session.setConfig("StrictHostKeyChecking", "no");
if(identityFile != null)
{
jsch.addIdentity(identityFile);
}
if(targetPassword != null)
{
session.setPassword(targetPassword);
}
session.connect();