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();