我嘗試使用 ed25519 身份驗證設置 SFTP 上傳,但不斷收到此錯誤:線程“main”中的異常 java.lang.UnsupportedOperationException:不知道如何解碼密鑰:ssh-ed25519這是我的代碼:import java.io.File;import java.io.IOException;import net.schmizz.sshj.SSHClient;import net.schmizz.sshj.sftp.SFTPClient;import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile;import net.schmizz.sshj.xfer.FileSystemFile;import net.schmizz.sshj.transport.verification.PromiscuousVerifier;String username = "scansionitesz"; String remoteDir = "files";String remoteFile = "prova_delega.pdf";String localDir = "C:/Users/VERSIM/Desktop";final SSHClient ssh = new SSHClient();ssh.addHostKeyVerifier(new PromiscuousVerifier());ssh.connect(server);try { File privateKey = new File(openSSHPrivateKey); KeyProvider keys = ssh.loadKeys(privateKey.getPath()); OpenSSHKeyFile key = new OpenSSHKeyFile(); key.init("-----BEGIN OPENSSH PRIVATE KEY-----\n" + "my_private_key\n" + "-----END OPENSSH PRIVATE KEY-----", "ssh-ed25519 my_public_key scansionitesz@tes" ); ssh.authPublickey(username,key); final SFTPClient sftp = ssh.newSFTPClient(); try { sftp.put(new FileSystemFile(localDir + "/" + remoteFile), "/" + remoteDir); } finally { sftp.close(); }} finally { ssh.disconnect();}我缺少什么?
添加回答
舉報
0/150
提交
取消