Copying files internally on an SFTP server using Spring integration/JCraft JSch











up vote
1
down vote

favorite
1












I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.



So far I haven't been able to find any way to do this without an intermediary.



Another approach would be to open an SSH channel and just use the cp command but well that's not too pretty either in my opinion.



Thanks in advance!










share|improve this question
























  • You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
    – Castaglia
    Jun 6 '16 at 19:29












  • Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
    – Roddy of the Frozen Peas
    Nov 9 at 23:16















up vote
1
down vote

favorite
1












I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.



So far I haven't been able to find any way to do this without an intermediary.



Another approach would be to open an SSH channel and just use the cp command but well that's not too pretty either in my opinion.



Thanks in advance!










share|improve this question
























  • You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
    – Castaglia
    Jun 6 '16 at 19:29












  • Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
    – Roddy of the Frozen Peas
    Nov 9 at 23:16













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.



So far I haven't been able to find any way to do this without an intermediary.



Another approach would be to open an SSH channel and just use the cp command but well that's not too pretty either in my opinion.



Thanks in advance!










share|improve this question















I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch.



So far I haven't been able to find any way to do this without an intermediary.



Another approach would be to open an SSH channel and just use the cp command but well that's not too pretty either in my opinion.



Thanks in advance!







java spring copy sftp jsch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 6 '16 at 20:09









Martin Prikryl

83.4k22154342




83.4k22154342










asked Jun 6 '16 at 18:38









user3157264

44210




44210












  • You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
    – Castaglia
    Jun 6 '16 at 19:29












  • Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
    – Roddy of the Frozen Peas
    Nov 9 at 23:16


















  • You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
    – Castaglia
    Jun 6 '16 at 19:29












  • Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
    – Roddy of the Frozen Peas
    Nov 9 at 23:16
















You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29






You might be able to get this behavior by using a site-to-site transfer (a.k.a. "FXP") with that same server itself. I.e. your FTP client opens two FTP sessions to the server; one session tells the server to use a passive data transfer (e.g. for receiving the file), the other session tells the server to do an active data transfer (e.g. for sending the file), and you use the address/port from the passive data response in the active data command.
– Castaglia
Jun 6 '16 at 19:29














Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16




Possible duplicate of How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?
– Roddy of the Frozen Peas
Nov 9 at 23:16












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










A core SFTP protocol does not support duplicating a remote file.



There's a draft of copy-file extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).



It's definitely not supported by the most widespread OpenSSH SFTP server.



And it's also not supported by the JSch library.





See also my answer to How can I copy/duplicate a file to another directory using SFTP?





So actually using the cp shell command over an "exec" channel (ChannelExec) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).





If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:




  • How do I transfer a file from one directory to another using Java SFTP Library JSch?

  • How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?






share|improve this answer























  • Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
    – user3157264
    Jun 6 '16 at 20:40











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37664612%2fcopying-files-internally-on-an-sftp-server-using-spring-integration-jcraft-jsch%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










A core SFTP protocol does not support duplicating a remote file.



There's a draft of copy-file extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).



It's definitely not supported by the most widespread OpenSSH SFTP server.



And it's also not supported by the JSch library.





See also my answer to How can I copy/duplicate a file to another directory using SFTP?





So actually using the cp shell command over an "exec" channel (ChannelExec) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).





If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:




  • How do I transfer a file from one directory to another using Java SFTP Library JSch?

  • How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?






share|improve this answer























  • Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
    – user3157264
    Jun 6 '16 at 20:40















up vote
1
down vote



accepted










A core SFTP protocol does not support duplicating a remote file.



There's a draft of copy-file extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).



It's definitely not supported by the most widespread OpenSSH SFTP server.



And it's also not supported by the JSch library.





See also my answer to How can I copy/duplicate a file to another directory using SFTP?





So actually using the cp shell command over an "exec" channel (ChannelExec) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).





If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:




  • How do I transfer a file from one directory to another using Java SFTP Library JSch?

  • How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?






share|improve this answer























  • Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
    – user3157264
    Jun 6 '16 at 20:40













up vote
1
down vote



accepted







up vote
1
down vote



accepted






A core SFTP protocol does not support duplicating a remote file.



There's a draft of copy-file extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).



It's definitely not supported by the most widespread OpenSSH SFTP server.



And it's also not supported by the JSch library.





See also my answer to How can I copy/duplicate a file to another directory using SFTP?





So actually using the cp shell command over an "exec" channel (ChannelExec) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).





If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:




  • How do I transfer a file from one directory to another using Java SFTP Library JSch?

  • How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?






share|improve this answer














A core SFTP protocol does not support duplicating a remote file.



There's a draft of copy-file extension to the protocol, but that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example).



It's definitely not supported by the most widespread OpenSSH SFTP server.



And it's also not supported by the JSch library.





See also my answer to How can I copy/duplicate a file to another directory using SFTP?





So actually using the cp shell command over an "exec" channel (ChannelExec) is unfortunately the best available approach (assuming you connect to a *nix server and you have a shell access).





If you do not have a shell access, then your only option is indeed to download the file to a local temporary folder and upload it back to the new location (or use streams, to avoid a temporary file). See also:




  • How do I transfer a file from one directory to another using Java SFTP Library JSch?

  • How do I copy files stored in a remote SFTP server to another folder in the same remote server using Java?







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 19 at 10:22

























answered Jun 6 '16 at 20:07









Martin Prikryl

83.4k22154342




83.4k22154342












  • Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
    – user3157264
    Jun 6 '16 at 20:40


















  • Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
    – user3157264
    Jun 6 '16 at 20:40
















Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40




Thanks for your awnser. It's a shame that its not supported. It seems such a trivial task :)
– user3157264
Jun 6 '16 at 20:40


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37664612%2fcopying-files-internally-on-an-sftp-server-using-spring-integration-jcraft-jsch%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin