Estou tentando fazer o SFTP para um servidor usando a sequência de identidade: SSH-2.0-AWS_SFTP_1.0 com o seguinte código Java usando sshj.
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
<version>0.29.0</version>
</dependency>
private SSHClient setupSshj(String remoteHost, String username, String password) throws IOException {
SSHClient client = new SSHClient();
client.addHostKeyVerifier(new PromiscuousVerifier());
client.connect(remoteHost);
client.authPassword(username, password);
return client;
}
public void sftpfiles() throws IOException {
if (Boolean.parseBoolean(GetConfigValue("dds", "sendFiles"))) {
SSHClient sshClient = setupSshj(GetConfigValue("dds", "RemoteAddress"), GetConfigValue("dds", "RemoteLogin"), GetConfigValue("dds", "RemotePassword"));
SFTPClient sftpClient = sshClient.newSFTPClient();
sftpClient.put("/home/vm/test.txt", GetConfigValue("dds", "RemoteDirectory"));
sftpClient.close();
sshClients.disconnect();
}
}
e pegue o erro
Erro SETSTAT não suportado
Entendo que o serviço da AWS não permite definir carimbos de data / hora durante o upload, mas não sei quais ajustes são necessários para configurar o cliente SFTP.
Atenciosamente Conteh
Parece que a SSHClient
API sshj não permite impedir o uso da solicitação SETSTAT. Você precisará usar uma API de nível mais baixo, como SFTPFileTransfer
:
SFTPEngine engine = new SFTPEngine(sshClient).init();
SFTPFileTransfer xfer = new SFTPFileTransfer(engine);
xfer.setPreserveAttributes(false);
xfer.upload("/home/vm/test.txt", GetConfigValue("dds", "RemoteDirectory"));
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras