我尝试使用 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
提交
取消