I'm having a problem using SFTP Client. I'm getting no such file. I've
tried the relative path, and the absolute path. Here's the code:
try {
ConnectFuture connection =
VacationApplication.getSshClient().connect(m_user,server.getHostName(),server.getPort());
session = (ClientSessionImpl)connection.await().getSession();
AuthFuture authResult = session.authInteractive(m_user,m_password);
authResult.await(10000);
if (!authResult.isSuccess()){
if (authResult.getException()== null){
throw new IOException("Error authenticating.");
} else {
throw authResult.getException();
}
}
authenticated = true;
} catch (IOException ioe){
VacationApplication.log("VacationUser.login(\"" + m_user + "\",\"****\"),
Server:" + server.toString(),ioe);
} catch (InterruptedException ie){
VacationApplication.log("VacationUser.login()",ie);
} catch (Throwable t){
VacationApplication.log("VacationUser.login()",t);
}
SftpClient ftp = session.createSftpClient();
fileName="/home/"+m_user+"/"+fileName;
try {
InputStream is = client.read(fileName);
StreamUtils.streamToString(is);
is.close();
} catch (IOException ioe){
// this is ok
VacationApplication.log("Error retrieving file:"+fileName,ioe);
}
The error thrown is:
Sep 19, 2014 4:27:54 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Error retrieving file: /home/ft/.forward
SFTP error (2): No such file
at
org.apache.sshd.client.sftp.DefaultSftpClient.checkStatus(DefaultSftpClient.java:296)
at
org.apache.sshd.client.sftp.DefaultSftpClient.close(DefaultSftpClient.java:432)
at
org.apache.sshd.client.sftp.DefaultSftpClient$4.close(DefaultSftpClient.java:687)
at
com.mhsoftware.vacation.VacationUser.getTextFile(VacationUser.java:144)
at
com.mhsoftware.vacation.VacationUser.getCurrentSettings(VacationUser.java:101)
at org.apache.jsp.EditSettings_jsp._jspService(EditSettings_jsp.java:75)
On the server side, I see:
2014-09-19T16:27:53.806036-06:00 server sshd[25990]: Accepted
keyboard-interactive/pam for ft from xx.xxx.xxx.xxx port 47412 ssh2
2014-09-19T16:27:53.854612-06:00 server sshd[25994]: subsystem request for sftp
by user ft
If anyone could point me in the write direction, I'd appreciate it.
--
George Sexton
*MH Software, Inc.*
Voice: 303 438 9585
http://www.mhsoftware.com