Visit Our UNIX and Linux User Community


Chroot sftp users, remote sftp login shows wrong timestamp on files


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Chroot sftp users, remote sftp login shows wrong timestamp on files
# 1  
Old 09-24-2012
Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello,

I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration.
Code:
[root@host1 sftpdata]#pwd
/data/sftphome/sftpuser/sftpdata
[root@host1 sftpdata]# ls -lrt
total 34047
-rw-r--r-- 1 SFTPUSER1 sftpgroup   99853 Sep 24 01:59 file1
-rw-r--r-- 1 SFTPUSER1 sftpgroup     130 Sep 24 01:59 file2
-rw-r--r-- 1 SFTPUSER1 sftpgroup    4339 Sep 24 01:59 file3
-rw-r--r-- 1 SFTPUSER1 sftpgroup 3098614 Sep 24 01:59 file4
-rw-r--r-- 1 SFTPUSER1 sftpgroup 4100287 Sep 24 01:59 file5
-rw-r--r-- 1 SFTPUSER1 sftpgroup 4261072 Sep 24 01:59 file6
[root@host1 sftpdata]#

### when I login remotely via sftp with SFTPUSER1 to host1, I see different timestamp.
Code:
$ sftp SFTPUSER1@host1
Connecting to host1...
SFTPUSER1@host1's password:
sftp> ls
sftpdata     backup
sftp> cd sftpdata
sftp> ls -lrt
-rw-r--r--    1 678      600         99853 Sep 24 05:59 file1
-rw-r--r--    1 678      600           130 Sep 24 05:59 file2
-rw-r--r--    1 678      600          4339 Sep 24 05:59 file3
-rw-r--r--    1 678      600       3098614 Sep 24 05:59 file4
-rw-r--r--    1 678      600       4100287 Sep 24 05:59 file5
-rw-r--r--    1 678      600       4261072 Sep 24 05:59 file6
sftp> bye
$


Thanks,
# 2  
Old 09-24-2012
Have you checked if the timezone setting for both the machines are same?

SFTP protocol expects times in UTC, so the server sends in a format which gets misinterpreted by the client, whereas in case of ssh, the commands get executed on the server and the output gets transferred to the client, leaving no chance for misinterpretation.
This User Gave Thanks to admin_xor For This Post:
# 3  
Old 09-25-2012
Yes, I checked both servers are in same time zone.

If I sftp to same server, as a user which is not part for chroot'ed group, I dont see any difference in timestamp, its perfectly the same.

I see this issue only with chroot'ed group users, any idea who to disable this from misinterpreting.
# 4  
Old 09-25-2012
I'm with the TZ concept as well.

grep for TZ in the chroot jail files - they should local copies and not symlinks out of the jail, right?
# 5  
Old 09-25-2012
They are local copies, not sym links.

as suggested I tried grep for TZ, via logging in as sftp remotely, there is no grep command for sftp session.
# 6  
Old 09-25-2012
Well, the timezone information is usually /etc/localtime. Please check if this is a standalone file in the chroot's etc directory (where sftp gets chrooted to) or a symbolic link to the global /etc/localtime
This User Gave Thanks to admin_xor For This Post:
# 7  
Old 09-26-2012
Hello,

Here is existing file localtime in shown below. The Chroot directory under /etc/ssh/sshd_config is pointing users home directory. I did not created and symlinks pointing to localtime.

so your suggesting me cp this file, to /usr/share/zoneinfo/America/New_York to userhome directory and name is it as "localtime" ??

Code:
# ls -l /etc/localtime
lrwxrwxrwx 1 root root 36 Jun 14 11:24 /etc/localtime -> /usr/share/zoneinfo/America/New_York
# grep ChrootDirectory /etc/ssh/sshd_config
#ChrootDirectory none
         ChrootDirectory /data/sftphome/%u
#

Thanks

Previous Thread | Next Thread
Test Your Knowledge in Computers #876
Difficulty: Medium
All operational code must be POSIX compliant in order to be cost effective.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rename (move) multiple files on remote server using sftp

I want to rename (move) multiple files on remote server. I tried the following command to move all TXT files from my_dir directory to /new_dir. But it does not work. Any help? #!/bin/ksh sftp -dev3 << ABC cd my_dir $(for i in TXT; do echo "ls *.$i" ; rename $x /new_dir/$x;... (1 Reply)
Discussion started by: Soham
1 Replies

2. Shell Programming and Scripting

Test if Remote server is up and running before SFTP'ing files (in batch mode)

Hello, In our Data Warehouse environment, before our batch SFTP jobs kick off to pull the files from remote servers, I would like to setup a pre-sftp job that would test if all the remote servers from where the files are being pulled, are up and running. If any one of the remote serer is... (2 Replies)
Discussion started by: Dippu
2 Replies

3. Shell Programming and Scripting

Help with moving files on remote server using sftp

I need to sftp a file ABC_sysdate.csv (File name with system date and timestamp) to a temporary directory on the remote server and once the file is copied I've to move the file from temporary directory to the main directory with the same name. I have to generate a new file every hour and repeat... (6 Replies)
Discussion started by: srinup
6 Replies

4. Shell Programming and Scripting

SFTP script to automate login in to remote server

Greetings, guys. I'm not much of a programmer forgive me for being a noob, because of someone leaving, I was put in an IT spot where I have to figure out a few things. Being new to Linux and programming has been a challenge. My boss has asked me to create an automated script to connect to a 3rd... (7 Replies)
Discussion started by: giovannym
7 Replies

5. AIX

sftp chroot + winbind + ad

I have next configuration : - AIX 5.3 (5300-11-03-1013) - pWare.SAMBA 3.5.8.1 - OpenSSH 5.2.0 - OpenSSL 0.9.8 Now, to be more clearly I'll explain what I need indeed. My task is set up integration AIX server to Active Directory 2008 with Samba (Winbind) for chrooted SSH connections. It... (3 Replies)
Discussion started by: jess_t03
3 Replies

6. Red Hat

sftp jail chroot env setup

Hi I need a specific user to be able to sftp to a server and get files from a specific location. The location is not the users home dir, i don't want the user to be able to view anything else apart from the files in that area. e.g ftp file are is - /logging/phplogs e.g user home is... (1 Reply)
Discussion started by: duckeggs01
1 Replies

7. Red Hat

chroot sftp, samba share, ownership issue linux hosts

Hello, I have sftp server with chroot for a group and username is on a Linux host, I have created a few subdirectories under sftpuser home directories with 775. Then using a Samba I shared this user home directory to another linux client. On the Linux client, I have jboss user to access... (2 Replies)
Discussion started by: bobby320
2 Replies

8. Shell Programming and Scripting

Remove remote files using SFTP

Hello All, I am really looking for your help regards to the below issue.:wall: My requirement is to get the files from the remote server using SFTP and then remove the retrieved files in the remote directory. File names are unique in the remote directory. so first I will need to get the... (5 Replies)
Discussion started by: vinayparakala
5 Replies

9. Solaris

SSH & SFTP Chroot

Hello all, does anybody knows a procedure to enable an chroot for users using ssh and sftp ? Thanks (1 Reply)
Discussion started by: celord
1 Replies

10. Solaris

SFTP is successful but still shows timeout error

Hi, I am doing sftp from remote server1 to remote server2. This is done through a script. This script was working fine. But if i am tranfer files of 120 MB only some part of the file gets transferred (around 9 MB). Incase i put the same file manually it gets uploaded successfully. Can... (1 Reply)
Discussion started by: subiksha
1 Replies

Featured Tech Videos