LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-19-2020, 07:57 AM   #1
Cichowczyc
LQ Newbie
 
Registered: Feb 2020
Posts: 4

Rep: Reputation: Disabled
SFPT - Vsftpd on Ubuntu: Disallow client timestamp on uploaded files.


Hi,

I'm running vsftpd on a Ubuntu server. I'd need vsftpd to disallow the timestamp on files it receives from clients. Right now the behaviour is that the uploaded files get the timestamp from the files itself using WINSCP with Preserve Timestamp option enabled. I'd like to make config on server side witch disalowed clients such as WINSCP to preserve timestamps.

I done some research and try different options with mdtm_write=NO in conf file but nothing works.

vsftpd: version 3.0.3

Thanks !
 
Old 02-19-2020, 10:06 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,728

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by Cichowczyc View Post
Hi,

I'm running vsftpd on a Ubuntu server. I'd need vsftpd to disallow the timestamp on files it receives from clients. Right now the behaviour is that the uploaded files get the timestamp from the files itself using WINSCP with Preserve Timestamp option enabled. I'd like to make config on server side witch disalowed clients such as WINSCP to preserve timestamps.

I done some research and try different options with mdtm_write=NO in conf file but nothing works.

vsftpd: version 3.0.3

Thanks !
Are you sure your clients are using FTP? The default with WinSCP is to use SFTP, which uses sshd on the server side, not vsftpd.
 
Old 02-19-2020, 12:49 PM   #3
Cichowczyc
LQ Newbie
 
Registered: Feb 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Worth to mention I'm new in linux

You're right, this is SFTP connection via port 22. To be precise this is a VM on Azure with linux ubuntu witch I configured with this tutorial (except that I deny access for port 21 in NSG):

https://dev.to/aloneguid/setting-up-...oft-azure-2npb

After that sFTP works fine and I thought it was because vsftpd. Looks like I should go into sshd config now.

Edit: Cant find any solution Need Your help.

Last edited by Cichowczyc; 02-20-2020 at 07:10 AM.
 
Old 02-28-2020, 07:33 AM   #4
Cichowczyc
LQ Newbie
 
Registered: Feb 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Still no luck, anyone?
 
Old 02-28-2020, 07:43 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
If you are using SFTP, then you can (and should) remove vsftpd from your server.

As for the date-time stamps, can you describe your task in a little more detail or in different words? If you are copying a file to your server using SFTP, it gets the time-date of its arrival on the server, not its original time-date. If you wish to preserve the the original time-date, then use the -p option with the SFTP client, or with the get or put command within SFTP.

However, if you are not using the regular SFTP client but WinSCP instead, look to the documentation for WinSCP instead. Or else try a different client.
 
Old 02-28-2020, 08:27 AM   #6
Cichowczyc
LQ Newbie
 
Registered: Feb 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
If you are using SFTP, then you can (and should) remove vsftpd from your server.

As for the date-time stamps, can you describe your task in a little more detail or in different words? If you are copying a file to your server using SFTP, it gets the time-date of its arrival on the server, not its original time-date. If you wish to preserve the the original time-date, then use the -p option with the SFTP client, or with the get or put command within SFTP.

However, if you are not using the regular SFTP client but WinSCP instead, look to the documentation for WinSCP instead. Or else try a different client.
In my task I share SFTP with multiple users. They can use several SFTP clients, I really don't know which one. Now, when I use SFTP, my file gets timestamp from the server and that's correct. But if any of my clients use winSCP with preserve timestamp option on (it's on by default) - the file save orginal timestamp. And that's not correct. I try to configure my server to dissalow that option. I need timestamp from server all the time.
 
Old 02-28-2020, 08:41 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
Over on the server itself, see which protocol features there are:

Code:
/usr/lib/openssh/sftp-server -Q requests
Then you can block all attribute changes for any SFTP activity by banning setstat and fsetstat in sshd_config:

Code:
Subsystem       sftp    internal-sftp -P setstat,fsetstat
Or

Code:
Subsystem       sftp    /usr/lib/openssh/sftp-server -P setstat,fsetstat

There are side effects. That will also block the built-in chmod and related tools.

See "man sftp-server" for the -Q and -P options.
 
1 members found this post helpful.
Old 03-02-2020, 07:48 AM   #8
Cichowczyc
LQ Newbie
 
Registered: Feb 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
Over on the server itself, see which protocol features there are:

Code:
/usr/lib/openssh/sftp-server -Q requests
Then you can block all attribute changes for any SFTP activity by banning setstat and fsetstat in sshd_config:

Code:
Subsystem       sftp    internal-sftp -P setstat,fsetstat
Or

Code:
Subsystem       sftp    /usr/lib/openssh/sftp-server -P setstat,fsetstat

There are side effects. That will also block the built-in chmod and related tools.

See "man sftp-server" for the -Q and -P options.

Works untill I reboot :

When I upload files via WinSCP I get exeption and timestamp from server on my file. Works great

Then I reboot my machine and preserve timestamp in WinSCP works again.

Step-by-Step:
1. Create VM with Ubuntu Server 18.04 LTS
2. SSH -> Add --> Subsystem sftp /usr/lib/openssh/sftp-server -P setstat,fsetstat in sshd_config
3. Test ok - exception. Cant preserve timestamp
4. Disallow SSH on user (sudo usermod -s /usr/lib/openssh/sftp-server and add /usr/lib/openssh/sftp-serve in /etc/shells)
5. sudo chmod 0700 /home/user
6. test ok - exception.
7. Reboot
8. Test fail - Can preserve timestamp.


Ok. Figure it out. After I use that - 'sudo usermod -s /usr/lib/openssh/sftp-server user' sshd_config wont work for that user. How Can I restrict access to SSH for users and make them affected by my sshd_config in the same time?

Last edited by Cichowczyc; 03-04-2020 at 05:13 AM.
 
  


Reply

Tags
ftp, ftps



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
script to timestamp files with timestamp from directory eRJe Programming 4 11-13-2013 06:52 PM
vsftpd: How can I disallow files to and folders be uploaded in a certain directory? Furii Linux - Software 1 05-28-2012 12:56 PM
[SOLVED] problem with sfpt/ftp unix1adm Red Hat 23 09-26-2009 06:31 PM
vsftpd: keep client timestamp on uploaded file netjack Linux - Server 4 01-08-2009 09:31 AM
vsftpd disallow specific file types from being uploaded GUIPenguin Linux - General 2 04-08-2005 10:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:30 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