LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-28-2012, 03:46 PM   #1
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Rep: Reputation: 30
SFTP client that can sync via command line


Hello, i'm looking for a good, simple sftp client that can sync to my sftp server at the office.

I want to basically set it up as a backup program and need to have everything automated.

Can you point me in the right direction?
-Thanks
 
Old 08-28-2012, 09:15 PM   #2
fang0654
Member
 
Registered: Oct 2003
Location: New York, NY
Distribution: Ubuntu
Posts: 110

Rep: Reputation: 28
sftp works pretty well. If you set up public key authentication, you can have it run automatically.
 
Old 08-28-2012, 09:20 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As he implied, sftp (& scp, both part of ssh pkg) are in fact cli tools anyway.
Just because you can put a GUI over the top eg Filezilla, certainly doesn't mean you have to use one ...
scp is a simpler cmd to use/automate.
 
2 members found this post helpful.
Old 08-28-2012, 09:29 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,732

Rep: Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920
Just to add to the other posts I would suggest using public/private keys if not already using them.
If you actually want to "sync" the files with your office you can use rsync as another option.
 
Old 08-29-2012, 03:08 PM   #5
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
The problem with rsync is it is limited by the length of directories or filenames. Sometimes it misses whole directories because of this and I don't want to have to worry about this.

How do I go about setting up a public/private key? I have looked into it but just don't understand it well.

Also, it's funny I was looking for an sftp program and the program recommended to me is actually called sftp. Ironic that this is not the norm. It's like asking for a web browser and finding out the best one is called Web Browser. : )
 
Old 08-29-2012, 03:14 PM   #6
fang0654
Member
 
Registered: Oct 2003
Location: New York, NY
Distribution: Ubuntu
Posts: 110

Rep: Reputation: 28
I think the term SFTP actually comes from the program sftp, which is file transfers over ssh. Setting up a public/private keypair is usually pretty easy, but depends on the sending and receiving system.

This site gives a pretty simple howto:

http://rcsg-gsir.imsb-dsgi.nrc-cnrc....et/node31.html
 
Old 08-29-2012, 07:19 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The ssh pkg/tool actually consists of (at least) 4 parts
ssh - client
sshd - server
scp - remote cp over ssh
sftp - ftp over ssh

ie if you have the ssh rpms
libssh2-1.2.2-7.el6_2.3.x86_64
openssh-5.3p1-81.el6.x86_64
openssh-clients-5.3p1-81.el6.x86_64
openssh-server-5.3p1-81.el6.x86_64

the you'll have all the tools. Its really one tool with multiple options/personalities
See chap 9 http://www.linuxtopia.org/online_boo..._6_deployment/

Step by step key gen & setup http://www.thegeekstuff.com/2008/11/...n-ssh-copy-id/

Last edited by chrism01; 08-29-2012 at 07:20 PM.
 
Old 08-29-2012, 08:08 PM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i think like others mentioned you will have to set up public key encryption to allow passwordless access while ssh-ing into remote systems.

after you set that up, it should be fairly trivial to make a bash script to cp files. we can help if you explain what you mean by sync.
 
Old 08-30-2012, 05:29 PM   #9
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
OK, I want to have it so that the computer will backup files to the sftp server. Sync means that if i delete a file on my computer, the file is deleted on the server. If i add a new file or change an existing one, only the changes/new files get uploaded. Hence, the server is sync'd with my home computer. That way I can use it as a backup.

Is there a better way?
 
Old 08-30-2012, 07:56 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
In that case, you want the rsync tool http://linux.die.net/man/1/rsync.
If you're worried about security, you can require rsync to use ssh transport; see the many many threads on this subject.
 
Old 08-30-2012, 08:30 PM   #11
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
I have tried rsync but it doesn't get all the files. Like if the file has a long filename or there are a bunch of directories, rsync will miss that stuff.

I'm just looking for something that can get everything.
 
Old 08-31-2012, 06:59 AM   #12
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by xmrkite View Post
OK, I want to have it so that the computer will backup files to the sftp server. Sync means that if i delete a file on my computer, the file is deleted on the server. If i add a new file or change an existing one, only the changes/new files get uploaded. Hence, the server is sync'd with my home computer. That way I can use it as a backup.
most of the time sync'ing means taking the newest version of the file and overwriting the old version.
(e.g.- doc-1.txt on the server has a newer datestamp than the doc-1.txt file on the fone, then the file on the fone gets overwritten; song-1.mp3 has a newer date on the mp3-player than the one on the pc, then song-1.mp3 on the pc gets overwritten with the version from the mp3-player)

i think what you are actually referring to is a 1-way backup. rsync is probably your best bet so finding out what parameters you should use to correct your previous issues would yield you better mileage.

but if you are steadfast against using rsync then something like this this mite work:
Code:
find . -newer xmrkite.date /path/to/backup-dir -exec scp '{}' user@host:'{}' \; && touch xmrkite.date
maybe run this every hour or so.

Last edited by schneidz; 08-31-2012 at 07:09 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] SFTP ls drops connection from cron, but not from command line gjbloom Red Hat 2 08-06-2012 09:41 AM
How to use scp or sftp command line with a key file astroboiii Linux - Server 4 10-07-2010 11:27 AM
LXer: Newsbeuter: Command Line Feed Reader With Bloglines Sync Support LXer Syndicated Linux News 0 01-15-2010 09:30 PM
iPod sync from command line? prol Linux - Software 1 08-06-2008 02:04 PM
command line ftp client keevitaja Linux - Software 2 09-12-2002 04:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration