Step 1: Session connect
....
session.connect()
Step 2: Shell channel
channel = session.openChannel("shell");
Step 3: Execute ssh commands to login Unix server and go to the required path cd /logs/server
PrintStream shellStream = new PrintStream(channel.getOutputStream()); // printStream for convenience
channel.connect();
shellStream.println(command);
shellStream.flush();
step 4: Get the file from Unix server and put into SFTP:
code to connect sftp channel and put the file from unix server to sftp.
So I want to upload the file (logs/server/server.log
) from Unix server (which I logged in using shell channel) to SFTP server.
Both source and destination are remote.
Is it possible to do by using JSch?