Reputation: 931
Command-line sftp in my Ubuntu doesn't have recursive put implemented. I found some debate from 2004 about implementing such feature with -R option switch. So I see some sort of self-made recursion as only option.
Ie.
I'm planning on doing this with bash, but any other language would suffice.
Rsync or scp is not an option because I don't have shell access to server. Only sftp.
Upvotes: 14
Views: 29960
Reputation: 488
Here is how --
sftp -r <host>
password: <pass>
cd <remote dir> # moves to remote dest dir
put -r localdir/* # creates dir and copies files over
Upvotes: 0
Reputation: 1500
On the command line you can do that by using the putty-tools package.
It comes with a sftp replacement called psftp
.
It supports mput -r
which copies a local directory to the remote recursively.
Upvotes: 1
Reputation: 5754
While I think lftp is the best option if it's available, I got stuck on an ancient install of Cent OS and needed to do a recursive put via SFTP only. Here's what I did:
find dir -type d -exec echo 'mkdir {}' \; | sftp user@host
find dir -type f -exec echo 'put {} {}' \; | sftp user@host
So basically make sure all the directories exist and then send the files over.
Upvotes: 4
Reputation: 31353
The GUI FTP client FileZilla also supports SFTP and also supports uploading and downloading while directories.
Upvotes: 2
Reputation: 4962
Look at lftp. It's a powerful file transfer client which supports ftp, ftps, http, https, hftp, fish (file transfer over ssh shell session) and sftp. It has ftp-like interactive interface, but also allows to specify all commands at the command line. Look at mput
(non recursive but handles glob patterns) and mirror
(poor man's rsync) commands.
I use it with a server which only handles sftp uploads like this:
lftp -c "open -u $MYUSER,$MYPASSWORD sftp://$TARGET ; mirror -R $SOME_DIRECTORY"
Upvotes: 16
Reputation: 931
After lot's of googling and good answers I used Transmit syncing for the job. Not a very good solution, but does the job.
Upvotes: 0
Reputation: 42090
How about sshfs?
Combined, of course, with cp -r
.
Or, failing that, rsync -r
by itself.
Upvotes: 0
Reputation: 1006
In Java, you can use edtFTPj/PRO, our commercial product, to transfer recursively via SFTP. Alternatively you might want to consider SCP - that generally supports recursion and runs over SSH.
Upvotes: 0
Reputation: 328840
I guess you can do this with bash but it's going to be a lot of work. Instead, I suggest to have a look at Python and the Chilkat library.
Upvotes: 0