问题
I am trying to copy a file over SFTP to another Host using Jcraft JSch (http://www.jcraft.com/jsch/). I am getting below error:
Connecting via SSH to somehost:22
com.jcraft.jsch.JSchException: java.io.IOException: Pipe closed
at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:315)
at com.jcraft.jsch.Channel.connect(Channel.java:152)
at com.jcraft.jsch.Channel.connect(Channel.java:145)
Relevant code is below:
Channel channel = null;
ChannelSftp channelSftp = null;
Exception cause = null;
try {
connect();
channel = session.openChannel( "sftp" );
channelSftp = (ChannelSftp)channel;
channelSftp.connect();
assert channelSftp != null;
try {
channelSftp.ls( destDir );
} catch( SftpException sftpEx ) {
// Create destination folder, if it does not exist
execCommand( "some command" + destDir );
}
This was all good since last week, upgrading to latest jcraft version doesn't work. I referred to this and this (refer last comment on page), but could not reach to root cause. Any help?
回答1:
SSH was working without any issue. Problem was with SFTP module path in SSH config. Below link was not accessible.
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
来源:https://stackoverflow.com/questions/42714133/com-jcraft-jsch-jschexception-java-io-ioexception-pipe-closed