Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 21st, 2008, 11:09 AM
fountain_spray fountain_spray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 38 fountain_spray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 42 m 25 sec
Reputation Power: 1
Cool SFTP inbound files: Seen before closed?

Hello,

A customer uses SFTP to put (i.e. "push") files to our
External Linux server (Legacy Linux 7.2).

Our Internal Linux server constantly loops and scans customer
directories on that External server, looking for inbound files.

When an inbound file is found, it is copied via ssh rsync from
the External server to the Internal server, where it gets
decrypted.

Problem: Internal server is recognizing files written by SFTP
before those files arrive in their entirety. This results in
decryption errors on the Internal server when an incomplete
file is copied to there.

This problem does not occur if a customer stores their file
with FTP. The Internal server does not detect an FTP'd file
until it is written in its entirety.

Is this because FTP stores files more quickly than SFTP ?

Or is it because files stored by FTP are not created in the
directory until they are closed? SFTP'd files seem to be available in their directory as soon as they start to be written, ahead of when they complete and are closed.

Can the behavior of SFTP be changed by a CONFIG file
entry? If so, what is that entry and where is it located?

Have suggested our SFTP customer store their files in a
/TMP directory, then move to the scanned directory once
SFTP completes the put and displays the command prompt.

The customer is resisting, need a convincing explanation.

Thank you.

Reply With Quote
  #2  
Old April 21st, 2008, 11:17 AM
fountain_spray fountain_spray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 38 fountain_spray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 42 m 25 sec
Reputation Power: 1
More info from original poster:

SFTP does its own transparent encryption.

In additon to that, customer encrypts with PGP.

So, Internal server must decrypt with PGP after the
SFTP transparent decryption takes place.

Reply With Quote
  #3  
Old May 2nd, 2008, 11:02 AM
fountain_spray fountain_spray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 38 fountain_spray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 42 m 25 sec
Reputation Power: 1
Angry Is the Entire Linux Community STUMPED???

If you do not have a primo answer, I will settle for a bs answer.

SFTP files are visible in the directory before they are
fully written.

This is not the case with FTP.

Therefore an remote site cannot simply to transition to
SFTP withou wreaking major havoc on the support
implemented on the receiving host, which formerly
used FTP.

The allure of SFTP is the SSH security on the userid
and password. So what? We have never been hacked.

Hasn't anyone else had to deal with this issue?!?!?!

Fountain_spray

Reply With Quote
  #4  
Old May 2nd, 2008, 12:27 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 610 fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 15 h 24 m 48 sec
Reputation Power: 177
I assume your concern is that you have another process/daemon that looks for the file's existance, and then starts some process. It gets confused when the file is visible but not all there.

If so, here is a simple work arround, not elegant, but should work. Assume you want to send 'bigdatafile' which is big enough to take some time, more than a meg or two.

Change your daemon to look for 'doorbell' file.
then have your client first sftp 'bigdatafile' file, than then send a tiny file called 'doorbell'

Reply With Quote
  #5  
Old May 3rd, 2008, 05:14 AM
atlantisstorm atlantisstorm is offline
Hang your freedom higher.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 14 m 2 sec
Reputation Power: 113
I'd kinda agree with fishtoprecords suggestion. I've previously got around similiar issue by first sending a <filename>.start file, then sending <filename> followed by <filename>.complete - obviously <filename>.start and <filename>.complete are just empty marker files. In your case, you probably just need to check for the presence of <filename>.complete files.
__________________
"Badges? We ain't got no badges. We don't need to badges! I don't have to show you any stinkin' badges!!"

Reply With Quote
  #6  
Old May 6th, 2008, 10:43 AM
fountain_spray fountain_spray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 38 fountain_spray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 42 m 25 sec
Reputation Power: 1
Wink Thank you but...

Hello fishtoprecords and atlantisstorm,

Thank you both for venturing a solution.

Our application dispatches an independent task for each file
that gets found by our directory-watch "scanner" process
(written in c++). Everything else is in Perl, with some bash.

Our scanner runs continuously and without delay.

So, lets say bigfile is found. Our dispatcher will create a
task and call the top-level processing "wrapper" program.
I can have the wrapper program read in a control file
that will only be set if a prior doorbell inbound file was
retrieved. If not set, wrapper shall terminate further
processing of the task for the assumed incomplete bigfile.

When a doorbell file enters our dispatching process, we
write to a control file. The next time our scanner
presents bigfile to dispatcher, dispatcher kicks off wrapper.

Wrapper shall read the doorbell control file to see if the
doorbell has "rung". If so, then reset the doorbell control
file and process bigfile.

That said, our customer has sworn to do nothing special for
us. That is, they will not so much as write a doorbell file.

So, a variation on the doorbell concept would be to check
the customer-ID. If this file is from the SFTP push customer,
then store the size of the file into a control file. Check that
control file the next time a task is created for that file
(instead of a doorbell file). Compare the sizes, and if equal,
then process. If not equal, then store the new size,
terminate that task, and await the next dispatcher task
for that file.

Here is my quick and dirty solution:

Use CRONtab to activate a process that handles recycling the
scanner.

Change the default scanner to leave out the inbound folder
of our SFTP push customer from continuous scanning.

Then, once a day, turn off scanning for all other customer
inbound folders, and turn on scanning for the inbound folder
of our SFTP push customer.

That way, unless the SFTP push customer is sending a file
at that moment, any files that have accumulated in their
inbound folder will have been fully written and closed by then.

After say, 1 minute, turn off scanning for the SFTP push
customer inbound folder and turn on scanning for all other
customers.

This may cause its own set of problems, as not all processes
will have been killed between each recycling of the scanner
process.

But this is the only way I can address the issue as framed
by our customer without having to beg or write alot of code.

fountain_spray

Reply With Quote
  #7  
Old May 6th, 2008, 05:55 PM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God (5000 - 5499 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,394 ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level)ishnid User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 5 Days 14 h 14 m 24 sec
Reputation Power: 1259
Have you tried to see what the behaviour is using FTPS (over SSL, rather than SSH)? That may be an alternative way to bring encryption into it, and it should behave more like normal FTP.

Reply With Quote
  #8  
Old May 7th, 2008, 09:15 AM
fountain_spray fountain_spray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 38 fountain_spray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 42 m 25 sec
Reputation Power: 1
Lightbulb Our Linux Does Not Support SSL

Hello Ishnid,

Great suggestion, but as our Legacy Linux 7.2 from
RedHat does not contain SSL support, therefore
we do not have FTPS available.

Besides, our customer decided on SSH/SFTP so
we are obliged to support that.

Fountain_spray

Last edited by fountain_spray : May 12th, 2008 at 08:19 AM.

Reply With Quote
  #9  
Old May 12th, 2008, 08:22 AM
fountain_spray fountain_spray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 38 fountain_spray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 42 m 25 sec
Reputation Power: 1
The way: fuser or lsof

Hello folks,

The best solution is to use either of these commands to
determine if the file is still being written to:

/sbin/fuser -a -u -v /pathname/filename

/usr/sbin/lsof -u userid

Thanks all.

Fountain_spray

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > SFTP inbound files: Seen before closed?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway