Uploading directories with sftp?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm having some trouble uploading directories(which contain other directories a few levels deep) by sftp. I realize I could work around this by gzipping, but I don't see why that's necessary.
Anyway, I try
sftp> put bin/
Uploading bin/ to /home/earlz/blah/bin
bin/ is not a regular file
sftp> put -r bin/
Uploading bin/ to /home/earlz/blah/bin
Couldn't canonicalise: No such file or directory
Unable to canonicalise path "/home/earlz/blah/bin"
I think the last error message is completely stupid. So the directory doesn't exist? Why not create the directory?
Is there anyway around this issue with sftp, or should I just use scp?
linux ssh sftp
add a comment |
I'm having some trouble uploading directories(which contain other directories a few levels deep) by sftp. I realize I could work around this by gzipping, but I don't see why that's necessary.
Anyway, I try
sftp> put bin/
Uploading bin/ to /home/earlz/blah/bin
bin/ is not a regular file
sftp> put -r bin/
Uploading bin/ to /home/earlz/blah/bin
Couldn't canonicalise: No such file or directory
Unable to canonicalise path "/home/earlz/blah/bin"
I think the last error message is completely stupid. So the directory doesn't exist? Why not create the directory?
Is there anyway around this issue with sftp, or should I just use scp?
linux ssh sftp
add a comment |
I'm having some trouble uploading directories(which contain other directories a few levels deep) by sftp. I realize I could work around this by gzipping, but I don't see why that's necessary.
Anyway, I try
sftp> put bin/
Uploading bin/ to /home/earlz/blah/bin
bin/ is not a regular file
sftp> put -r bin/
Uploading bin/ to /home/earlz/blah/bin
Couldn't canonicalise: No such file or directory
Unable to canonicalise path "/home/earlz/blah/bin"
I think the last error message is completely stupid. So the directory doesn't exist? Why not create the directory?
Is there anyway around this issue with sftp, or should I just use scp?
linux ssh sftp
I'm having some trouble uploading directories(which contain other directories a few levels deep) by sftp. I realize I could work around this by gzipping, but I don't see why that's necessary.
Anyway, I try
sftp> put bin/
Uploading bin/ to /home/earlz/blah/bin
bin/ is not a regular file
sftp> put -r bin/
Uploading bin/ to /home/earlz/blah/bin
Couldn't canonicalise: No such file or directory
Unable to canonicalise path "/home/earlz/blah/bin"
I think the last error message is completely stupid. So the directory doesn't exist? Why not create the directory?
Is there anyway around this issue with sftp, or should I just use scp?
linux ssh sftp
linux ssh sftp
asked Feb 7 '11 at 3:04
EarlzEarlz
1,2811912
1,2811912
add a comment |
add a comment |
10 Answers
10
active
oldest
votes
CORRECTED: I initially claimed wrongly that OpenSSH did not support put -r. It does, but it does it in a very strange way. It seems to expect the destination directory to already exist, with the same name as the source directory.
sftp> put -r source
Uploading source/ to /home/myself/source
Couldn't canonicalize: No such file or directory
etc.
sftp> mkdir source
sftp> put -r source
Uploading source/ to /home/myself/source
Entering source/
source/file1
source/file2
What's especially strange is that this even applies if you give a different name for the destination:
sftp> put -r source dest
Uploading source/ to /home/myself/dest
Couldn't canonicalize: ...
sftp> mkdir dest
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Couldn't canonicalize: ...
sftp> mkdir dest/source
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Entering source/
source/file1
source/file2
For a better-implemented recursive put, you could use the PuTTY psftp command line tool instead. It's in the putty-tools package under Debian (and most likely Ubuntu).
Alternately, Filezilla will do what you want, if you want to use a GUI.
FYI:sftpallowsput -rfrom OpenSSH 5.4
– Tino
May 3 '16 at 12:04
3
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
add a comment |
I don't know why sftp does this but you can only recursive copy if the destination directory already exists. So do this...
sftp> mkdir bin
sftp> put -r bin
5
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
2
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
1
-rneeds OpenSSH 5.4 or higher
– Tino
May 3 '16 at 12:06
add a comment |
You might be interested in using rsync instead. The command for that would be
rsync --delete --rsh=ssh -av bin/ remote-ip-or-fqdn:/home/earlz/blah/bin/
This will copy everything in bin/ and place it in on the remote server in /home/earlz/blah/bin/. As an added benefit, it will first check to see if the file on the remote side hasn't changed, and if it hasn't, it won't re-send it. Additionally, you can add a -z option and it will compress it for you.
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
3
Please note thatsftpis a command and a protocol.rsyncdoes not support thesftp-protocol.
– Tino
May 3 '16 at 12:07
add a comment |
May I suggest a somewhat complicated answer, without zipping, but including tar?
Here we go:
tar -cf - ./bin | ssh target.org " ( cd /home/earlz/blah ; tar -xf - ) "
This will pack the directory ./bin with tar (-cf:=create file), filename - (none, stdout) and pipe it through the ssh-command to target.org (which might as well be an IP) where the command in quotes is performed, which is:
cd to blah, and tar -xf (extract file) - none, no name, just stdin.
It's as if you pack a package at home, bring it to the post, then drive to work, where you expect the package and open it.
Maybe there is a much more elegant solution which just uses sftp.
A pipedtaris a very good solution, however this needssshlogin support (sftpis a different protocol on top ofssh).tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)
– Tino
May 3 '16 at 12:22
I use this method when I need compression between nodes also you can use thepvtool to watch speed in long transfers
– Felipe Alcacibar
May 3 '17 at 14:40
add a comment |
lcd: your local folder (with subfolders)
cd: your remote folder
put -r .
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. Butcd'ing into the directory I wanted to upload did it. Thank you!
– karimkorun
Jul 7 '16 at 10:15
add a comment |
You can use yafc (Yet anoter FTP/SFTP client). The -r option works there very well.
add a comment |
You can use rsync, which is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).
for example :
rsync -zrp /home/a/ user@remote.host.com:/home/b/
The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.
Original answer by Karolos
add a comment |
Login to the remote server with ssh, use sftp to connect back to your box, then use the get -r command to transfer directories to the remote server.
The get command allows you to transfer directories recursively without having the directory already created.
ssh remote ip
sftp local ip
get -r whichever-dir
add a comment |
SFTP case:
I needed to copy that structure on my ftp:
mainfolder --- folder --- subfolder
| |
file1.txt file2.txt
That solved my problem:
cd ./mainfolder
mkdir folder
put -r /from/source/folder/* /mainfolder/folder/
cd ./folder
mkdir subfolder
put -r /from/source/folder/subfolder/* /mainfolder/folder/subfolder/
add a comment |
I just learned from the Arch Linux Wiki that it is possible to mount the sftp-share using sshfs. I'm running an sftp-server with chroot and jail and sshfs works very well.
- Mount:
sshfs <sftpuser>@<server>:<read/writable/directory> <your/local/mount/directory>
- Unmount:
fusermount -u <your/local/mount/directory>
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f7004%2fuploading-directories-with-sftp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
CORRECTED: I initially claimed wrongly that OpenSSH did not support put -r. It does, but it does it in a very strange way. It seems to expect the destination directory to already exist, with the same name as the source directory.
sftp> put -r source
Uploading source/ to /home/myself/source
Couldn't canonicalize: No such file or directory
etc.
sftp> mkdir source
sftp> put -r source
Uploading source/ to /home/myself/source
Entering source/
source/file1
source/file2
What's especially strange is that this even applies if you give a different name for the destination:
sftp> put -r source dest
Uploading source/ to /home/myself/dest
Couldn't canonicalize: ...
sftp> mkdir dest
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Couldn't canonicalize: ...
sftp> mkdir dest/source
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Entering source/
source/file1
source/file2
For a better-implemented recursive put, you could use the PuTTY psftp command line tool instead. It's in the putty-tools package under Debian (and most likely Ubuntu).
Alternately, Filezilla will do what you want, if you want to use a GUI.
FYI:sftpallowsput -rfrom OpenSSH 5.4
– Tino
May 3 '16 at 12:04
3
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
add a comment |
CORRECTED: I initially claimed wrongly that OpenSSH did not support put -r. It does, but it does it in a very strange way. It seems to expect the destination directory to already exist, with the same name as the source directory.
sftp> put -r source
Uploading source/ to /home/myself/source
Couldn't canonicalize: No such file or directory
etc.
sftp> mkdir source
sftp> put -r source
Uploading source/ to /home/myself/source
Entering source/
source/file1
source/file2
What's especially strange is that this even applies if you give a different name for the destination:
sftp> put -r source dest
Uploading source/ to /home/myself/dest
Couldn't canonicalize: ...
sftp> mkdir dest
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Couldn't canonicalize: ...
sftp> mkdir dest/source
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Entering source/
source/file1
source/file2
For a better-implemented recursive put, you could use the PuTTY psftp command line tool instead. It's in the putty-tools package under Debian (and most likely Ubuntu).
Alternately, Filezilla will do what you want, if you want to use a GUI.
FYI:sftpallowsput -rfrom OpenSSH 5.4
– Tino
May 3 '16 at 12:04
3
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
add a comment |
CORRECTED: I initially claimed wrongly that OpenSSH did not support put -r. It does, but it does it in a very strange way. It seems to expect the destination directory to already exist, with the same name as the source directory.
sftp> put -r source
Uploading source/ to /home/myself/source
Couldn't canonicalize: No such file or directory
etc.
sftp> mkdir source
sftp> put -r source
Uploading source/ to /home/myself/source
Entering source/
source/file1
source/file2
What's especially strange is that this even applies if you give a different name for the destination:
sftp> put -r source dest
Uploading source/ to /home/myself/dest
Couldn't canonicalize: ...
sftp> mkdir dest
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Couldn't canonicalize: ...
sftp> mkdir dest/source
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Entering source/
source/file1
source/file2
For a better-implemented recursive put, you could use the PuTTY psftp command line tool instead. It's in the putty-tools package under Debian (and most likely Ubuntu).
Alternately, Filezilla will do what you want, if you want to use a GUI.
CORRECTED: I initially claimed wrongly that OpenSSH did not support put -r. It does, but it does it in a very strange way. It seems to expect the destination directory to already exist, with the same name as the source directory.
sftp> put -r source
Uploading source/ to /home/myself/source
Couldn't canonicalize: No such file or directory
etc.
sftp> mkdir source
sftp> put -r source
Uploading source/ to /home/myself/source
Entering source/
source/file1
source/file2
What's especially strange is that this even applies if you give a different name for the destination:
sftp> put -r source dest
Uploading source/ to /home/myself/dest
Couldn't canonicalize: ...
sftp> mkdir dest
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Couldn't canonicalize: ...
sftp> mkdir dest/source
sftp> put -r source dest
Uploading source/ to /home/myself/dest/source
Entering source/
source/file1
source/file2
For a better-implemented recursive put, you could use the PuTTY psftp command line tool instead. It's in the putty-tools package under Debian (and most likely Ubuntu).
Alternately, Filezilla will do what you want, if you want to use a GUI.
edited May 3 '16 at 23:33
answered Feb 7 '11 at 6:17
JanderJander
11.9k43358
11.9k43358
FYI:sftpallowsput -rfrom OpenSSH 5.4
– Tino
May 3 '16 at 12:04
3
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
add a comment |
FYI:sftpallowsput -rfrom OpenSSH 5.4
– Tino
May 3 '16 at 12:04
3
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
FYI:
sftp allows put -r from OpenSSH 5.4– Tino
May 3 '16 at 12:04
FYI:
sftp allows put -r from OpenSSH 5.4– Tino
May 3 '16 at 12:04
3
3
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
Thanks -- I've corrected my answer. It's about time, huh? ;-P
– Jander
May 3 '16 at 23:34
add a comment |
I don't know why sftp does this but you can only recursive copy if the destination directory already exists. So do this...
sftp> mkdir bin
sftp> put -r bin
5
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
2
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
1
-rneeds OpenSSH 5.4 or higher
– Tino
May 3 '16 at 12:06
add a comment |
I don't know why sftp does this but you can only recursive copy if the destination directory already exists. So do this...
sftp> mkdir bin
sftp> put -r bin
5
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
2
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
1
-rneeds OpenSSH 5.4 or higher
– Tino
May 3 '16 at 12:06
add a comment |
I don't know why sftp does this but you can only recursive copy if the destination directory already exists. So do this...
sftp> mkdir bin
sftp> put -r bin
I don't know why sftp does this but you can only recursive copy if the destination directory already exists. So do this...
sftp> mkdir bin
sftp> put -r bin
answered Oct 16 '12 at 19:39
Useful DudeUseful Dude
1,271282
1,271282
5
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
2
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
1
-rneeds OpenSSH 5.4 or higher
– Tino
May 3 '16 at 12:06
add a comment |
5
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
2
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
1
-rneeds OpenSSH 5.4 or higher
– Tino
May 3 '16 at 12:06
5
5
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
This is the correct answer! :)
– sig11
Jul 29 '14 at 13:52
2
2
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
You really are a useful dude!
– justinpage
Jul 14 '15 at 23:21
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
it's working for me. thank's @Useful Dude
– Laukik Patel
Jan 29 '16 at 19:47
1
1
-r needs OpenSSH 5.4 or higher– Tino
May 3 '16 at 12:06
-r needs OpenSSH 5.4 or higher– Tino
May 3 '16 at 12:06
add a comment |
You might be interested in using rsync instead. The command for that would be
rsync --delete --rsh=ssh -av bin/ remote-ip-or-fqdn:/home/earlz/blah/bin/
This will copy everything in bin/ and place it in on the remote server in /home/earlz/blah/bin/. As an added benefit, it will first check to see if the file on the remote side hasn't changed, and if it hasn't, it won't re-send it. Additionally, you can add a -z option and it will compress it for you.
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
3
Please note thatsftpis a command and a protocol.rsyncdoes not support thesftp-protocol.
– Tino
May 3 '16 at 12:07
add a comment |
You might be interested in using rsync instead. The command for that would be
rsync --delete --rsh=ssh -av bin/ remote-ip-or-fqdn:/home/earlz/blah/bin/
This will copy everything in bin/ and place it in on the remote server in /home/earlz/blah/bin/. As an added benefit, it will first check to see if the file on the remote side hasn't changed, and if it hasn't, it won't re-send it. Additionally, you can add a -z option and it will compress it for you.
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
3
Please note thatsftpis a command and a protocol.rsyncdoes not support thesftp-protocol.
– Tino
May 3 '16 at 12:07
add a comment |
You might be interested in using rsync instead. The command for that would be
rsync --delete --rsh=ssh -av bin/ remote-ip-or-fqdn:/home/earlz/blah/bin/
This will copy everything in bin/ and place it in on the remote server in /home/earlz/blah/bin/. As an added benefit, it will first check to see if the file on the remote side hasn't changed, and if it hasn't, it won't re-send it. Additionally, you can add a -z option and it will compress it for you.
You might be interested in using rsync instead. The command for that would be
rsync --delete --rsh=ssh -av bin/ remote-ip-or-fqdn:/home/earlz/blah/bin/
This will copy everything in bin/ and place it in on the remote server in /home/earlz/blah/bin/. As an added benefit, it will first check to see if the file on the remote side hasn't changed, and if it hasn't, it won't re-send it. Additionally, you can add a -z option and it will compress it for you.
answered Feb 7 '11 at 19:24
Shawn J. GoffShawn J. Goff
30.3k19112134
30.3k19112134
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
3
Please note thatsftpis a command and a protocol.rsyncdoes not support thesftp-protocol.
– Tino
May 3 '16 at 12:07
add a comment |
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
3
Please note thatsftpis a command and a protocol.rsyncdoes not support thesftp-protocol.
– Tino
May 3 '16 at 12:07
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
Awsome! So simple!
– Asken
Jul 16 '13 at 9:47
3
3
Please note that
sftp is a command and a protocol. rsync does not support the sftp-protocol.– Tino
May 3 '16 at 12:07
Please note that
sftp is a command and a protocol. rsync does not support the sftp-protocol.– Tino
May 3 '16 at 12:07
add a comment |
May I suggest a somewhat complicated answer, without zipping, but including tar?
Here we go:
tar -cf - ./bin | ssh target.org " ( cd /home/earlz/blah ; tar -xf - ) "
This will pack the directory ./bin with tar (-cf:=create file), filename - (none, stdout) and pipe it through the ssh-command to target.org (which might as well be an IP) where the command in quotes is performed, which is:
cd to blah, and tar -xf (extract file) - none, no name, just stdin.
It's as if you pack a package at home, bring it to the post, then drive to work, where you expect the package and open it.
Maybe there is a much more elegant solution which just uses sftp.
A pipedtaris a very good solution, however this needssshlogin support (sftpis a different protocol on top ofssh).tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)
– Tino
May 3 '16 at 12:22
I use this method when I need compression between nodes also you can use thepvtool to watch speed in long transfers
– Felipe Alcacibar
May 3 '17 at 14:40
add a comment |
May I suggest a somewhat complicated answer, without zipping, but including tar?
Here we go:
tar -cf - ./bin | ssh target.org " ( cd /home/earlz/blah ; tar -xf - ) "
This will pack the directory ./bin with tar (-cf:=create file), filename - (none, stdout) and pipe it through the ssh-command to target.org (which might as well be an IP) where the command in quotes is performed, which is:
cd to blah, and tar -xf (extract file) - none, no name, just stdin.
It's as if you pack a package at home, bring it to the post, then drive to work, where you expect the package and open it.
Maybe there is a much more elegant solution which just uses sftp.
A pipedtaris a very good solution, however this needssshlogin support (sftpis a different protocol on top ofssh).tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)
– Tino
May 3 '16 at 12:22
I use this method when I need compression between nodes also you can use thepvtool to watch speed in long transfers
– Felipe Alcacibar
May 3 '17 at 14:40
add a comment |
May I suggest a somewhat complicated answer, without zipping, but including tar?
Here we go:
tar -cf - ./bin | ssh target.org " ( cd /home/earlz/blah ; tar -xf - ) "
This will pack the directory ./bin with tar (-cf:=create file), filename - (none, stdout) and pipe it through the ssh-command to target.org (which might as well be an IP) where the command in quotes is performed, which is:
cd to blah, and tar -xf (extract file) - none, no name, just stdin.
It's as if you pack a package at home, bring it to the post, then drive to work, where you expect the package and open it.
Maybe there is a much more elegant solution which just uses sftp.
May I suggest a somewhat complicated answer, without zipping, but including tar?
Here we go:
tar -cf - ./bin | ssh target.org " ( cd /home/earlz/blah ; tar -xf - ) "
This will pack the directory ./bin with tar (-cf:=create file), filename - (none, stdout) and pipe it through the ssh-command to target.org (which might as well be an IP) where the command in quotes is performed, which is:
cd to blah, and tar -xf (extract file) - none, no name, just stdin.
It's as if you pack a package at home, bring it to the post, then drive to work, where you expect the package and open it.
Maybe there is a much more elegant solution which just uses sftp.
answered Feb 7 '11 at 4:00
user unknownuser unknown
7,45112450
7,45112450
A pipedtaris a very good solution, however this needssshlogin support (sftpis a different protocol on top ofssh).tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)
– Tino
May 3 '16 at 12:22
I use this method when I need compression between nodes also you can use thepvtool to watch speed in long transfers
– Felipe Alcacibar
May 3 '17 at 14:40
add a comment |
A pipedtaris a very good solution, however this needssshlogin support (sftpis a different protocol on top ofssh).tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)
– Tino
May 3 '16 at 12:22
I use this method when I need compression between nodes also you can use thepvtool to watch speed in long transfers
– Felipe Alcacibar
May 3 '17 at 14:40
A piped
tar is a very good solution, however this needs ssh login support (sftp is a different protocol on top of ssh). tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)– Tino
May 3 '16 at 12:22
A piped
tar is a very good solution, however this needs ssh login support (sftp is a different protocol on top of ssh). tar, unlike others, by default, runs recursively, transfers all special files (FIFO, block/character devices etc.), tries to translate the UID/GID mapping from the source to the target system and has a traditional short commandline. (One exception though: "Unix domain sockets" are not transferred. But who needs those?)– Tino
May 3 '16 at 12:22
I use this method when I need compression between nodes also you can use the
pv tool to watch speed in long transfers– Felipe Alcacibar
May 3 '17 at 14:40
I use this method when I need compression between nodes also you can use the
pv tool to watch speed in long transfers– Felipe Alcacibar
May 3 '17 at 14:40
add a comment |
lcd: your local folder (with subfolders)
cd: your remote folder
put -r .
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. Butcd'ing into the directory I wanted to upload did it. Thank you!
– karimkorun
Jul 7 '16 at 10:15
add a comment |
lcd: your local folder (with subfolders)
cd: your remote folder
put -r .
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. Butcd'ing into the directory I wanted to upload did it. Thank you!
– karimkorun
Jul 7 '16 at 10:15
add a comment |
lcd: your local folder (with subfolders)
cd: your remote folder
put -r .
lcd: your local folder (with subfolders)
cd: your remote folder
put -r .
edited Feb 13 '15 at 18:46
jasonwryan
50.8k14135190
50.8k14135190
answered Feb 13 '15 at 18:37
eliseueliseu
8111
8111
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. Butcd'ing into the directory I wanted to upload did it. Thank you!
– karimkorun
Jul 7 '16 at 10:15
add a comment |
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. Butcd'ing into the directory I wanted to upload did it. Thank you!
– karimkorun
Jul 7 '16 at 10:15
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
actually, I think this is the most correct answer... for the purpose of putting my whole folder there
– 太極者無極而生
Jan 27 '16 at 14:21
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. But
cd'ing into the directory I wanted to upload did it. Thank you!– karimkorun
Jul 7 '16 at 10:15
sftp complained when I cd'd into the local parent folder and tried to put the directory by name. But
cd'ing into the directory I wanted to upload did it. Thank you!– karimkorun
Jul 7 '16 at 10:15
add a comment |
You can use yafc (Yet anoter FTP/SFTP client). The -r option works there very well.
add a comment |
You can use yafc (Yet anoter FTP/SFTP client). The -r option works there very well.
add a comment |
You can use yafc (Yet anoter FTP/SFTP client). The -r option works there very well.
You can use yafc (Yet anoter FTP/SFTP client). The -r option works there very well.
edited Jan 24 '12 at 12:00
sr_
13.2k3445
13.2k3445
answered Jan 24 '12 at 7:23
Dmitry ShpakovDmitry Shpakov
211
211
add a comment |
add a comment |
You can use rsync, which is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).
for example :
rsync -zrp /home/a/ user@remote.host.com:/home/b/
The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.
Original answer by Karolos
add a comment |
You can use rsync, which is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).
for example :
rsync -zrp /home/a/ user@remote.host.com:/home/b/
The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.
Original answer by Karolos
add a comment |
You can use rsync, which is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).
for example :
rsync -zrp /home/a/ user@remote.host.com:/home/b/
The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.
Original answer by Karolos
You can use rsync, which is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).
for example :
rsync -zrp /home/a/ user@remote.host.com:/home/b/
The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.
Original answer by Karolos
edited Mar 20 '17 at 10:04
Community♦
1
1
answered Jan 2 '16 at 22:42
SherlockSherlock
1111
1111
add a comment |
add a comment |
Login to the remote server with ssh, use sftp to connect back to your box, then use the get -r command to transfer directories to the remote server.
The get command allows you to transfer directories recursively without having the directory already created.
ssh remote ip
sftp local ip
get -r whichever-dir
add a comment |
Login to the remote server with ssh, use sftp to connect back to your box, then use the get -r command to transfer directories to the remote server.
The get command allows you to transfer directories recursively without having the directory already created.
ssh remote ip
sftp local ip
get -r whichever-dir
add a comment |
Login to the remote server with ssh, use sftp to connect back to your box, then use the get -r command to transfer directories to the remote server.
The get command allows you to transfer directories recursively without having the directory already created.
ssh remote ip
sftp local ip
get -r whichever-dir
Login to the remote server with ssh, use sftp to connect back to your box, then use the get -r command to transfer directories to the remote server.
The get command allows you to transfer directories recursively without having the directory already created.
ssh remote ip
sftp local ip
get -r whichever-dir
edited Sep 22 '16 at 11:43
Archemar
20.5k93973
20.5k93973
answered Sep 22 '16 at 11:19
Cyb3rT00thCyb3rT00th
1
1
add a comment |
add a comment |
SFTP case:
I needed to copy that structure on my ftp:
mainfolder --- folder --- subfolder
| |
file1.txt file2.txt
That solved my problem:
cd ./mainfolder
mkdir folder
put -r /from/source/folder/* /mainfolder/folder/
cd ./folder
mkdir subfolder
put -r /from/source/folder/subfolder/* /mainfolder/folder/subfolder/
add a comment |
SFTP case:
I needed to copy that structure on my ftp:
mainfolder --- folder --- subfolder
| |
file1.txt file2.txt
That solved my problem:
cd ./mainfolder
mkdir folder
put -r /from/source/folder/* /mainfolder/folder/
cd ./folder
mkdir subfolder
put -r /from/source/folder/subfolder/* /mainfolder/folder/subfolder/
add a comment |
SFTP case:
I needed to copy that structure on my ftp:
mainfolder --- folder --- subfolder
| |
file1.txt file2.txt
That solved my problem:
cd ./mainfolder
mkdir folder
put -r /from/source/folder/* /mainfolder/folder/
cd ./folder
mkdir subfolder
put -r /from/source/folder/subfolder/* /mainfolder/folder/subfolder/
SFTP case:
I needed to copy that structure on my ftp:
mainfolder --- folder --- subfolder
| |
file1.txt file2.txt
That solved my problem:
cd ./mainfolder
mkdir folder
put -r /from/source/folder/* /mainfolder/folder/
cd ./folder
mkdir subfolder
put -r /from/source/folder/subfolder/* /mainfolder/folder/subfolder/
answered Nov 24 '16 at 12:36
Nikita MalovichkoNikita Malovichko
1
1
add a comment |
add a comment |
I just learned from the Arch Linux Wiki that it is possible to mount the sftp-share using sshfs. I'm running an sftp-server with chroot and jail and sshfs works very well.
- Mount:
sshfs <sftpuser>@<server>:<read/writable/directory> <your/local/mount/directory>
- Unmount:
fusermount -u <your/local/mount/directory>
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I just learned from the Arch Linux Wiki that it is possible to mount the sftp-share using sshfs. I'm running an sftp-server with chroot and jail and sshfs works very well.
- Mount:
sshfs <sftpuser>@<server>:<read/writable/directory> <your/local/mount/directory>
- Unmount:
fusermount -u <your/local/mount/directory>
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I just learned from the Arch Linux Wiki that it is possible to mount the sftp-share using sshfs. I'm running an sftp-server with chroot and jail and sshfs works very well.
- Mount:
sshfs <sftpuser>@<server>:<read/writable/directory> <your/local/mount/directory>
- Unmount:
fusermount -u <your/local/mount/directory>
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I just learned from the Arch Linux Wiki that it is possible to mount the sftp-share using sshfs. I'm running an sftp-server with chroot and jail and sshfs works very well.
- Mount:
sshfs <sftpuser>@<server>:<read/writable/directory> <your/local/mount/directory>
- Unmount:
fusermount -u <your/local/mount/directory>
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 1 hour ago
saltanisaltani
1
1
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
saltani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f7004%2fuploading-directories-with-sftp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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