LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2018, 11:28 AM   #1
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
Problem listing remote directories in FTP (vsftp server)


I have vsftp running under LFS on my main computer (bigboy) and I am using gftp on my laptop (littleboy) to download dump tarballs. For those who haven't used gftp, it has a user interface similar to midnight commander, with the local and remote directories listed side by side, and arrows to do the transfers between them. This means that, unlike command line ftp, it has to get remote directory listings in order to function at all.

I have enabled local user login on the server. I find that I can get directory listings from /home/ftp but not from $HOME. The directory listing is empty and often the client disconnects. Why is this? I couldn't find anything in vsftp.conf that restricts directory listings in this way. There's nothing in vsftp's log either to suggest that it is misbehaving.

Last edited by hazel; 08-18-2018 at 11:29 AM.
 
Old 08-18-2018, 03:03 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,167
Blog Entries: 1

Rep: Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038
Quote:
I have enabled local user login on the server. I find that I can get directory listings from /home/ftp but not from $HOME. The directory listing is empty and often the client disconnects. Why is this? I couldn't find anything in vsftp.conf that restricts directory listings in this way. There's nothing in vsftp's log either to suggest that it is misbehaving.
Make sure that the directory in question (and all subdirectories underneath it) have the execute bit set, so they can be searchable. E.g:
Code:
chmod +x /home/user
 
Old 08-18-2018, 03:22 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,753

Rep: Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930
Could you post your vsftp.conf file?
 
Old 08-18-2018, 03:22 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Not familiar with vsftp specifically, but in my experience, ftp users don't "login" to a shell, so I wouldn't expect $HOME to be available, as that's a login shell variable.
[On my server, all ftp and email users have their shell set to /sbin/nologin...]

Edit: To clarify, by "ftp users" I mean users/accounts connecting via an ftp client to an ftp server...there's nothing special about the account itself, just the way in which it's connecting. Enabling login doesn't change that. I have users who could ssh or sftp, but if they ftp, they aren't "logged in"

Last edited by scasey; 08-18-2018 at 03:29 PM.
 
1 members found this post helpful.
Old 08-19-2018, 10:16 AM   #5
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628

Original Poster
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
I was using "$HOME" just in this post as a convenient abbreviation. When you use ftp as a local user, you are connected to your home directory automatically. You can specify in vsftpd.conf that users be confined to that directory. It's called a chroot but it isn't really because your home directory wouldn't have the facilities to be used as a real root partition (and of course there's no shell); it's just a jail. But I have left myself freedom to roam.

Here's my conf file.
Attached Files
File Type: txt vsftpd.conf.txt (4.6 KB, 33 views)

Last edited by hazel; 08-19-2018 at 11:00 AM.
 
Old 08-19-2018, 12:03 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by hazel View Post
I was using "$HOME" just in this post as a convenient abbreviation. When you use ftp as a local user, you are connected to your home directory automatically. You can specify in vsftpd.conf that users be confined to that directory. It's called a chroot but it isn't really because your home directory wouldn't have the facilities to be used as a real root partition (and of course there's no shell); it's just a jail. But I have left myself freedom to roam.

Here's my conf file.
Oh. Then I don't understand your OP at all, I guess. What were you using $HOME as a "convenient abbreviation" for, then?
 
Old 08-20-2018, 05:54 AM   #7
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628

Original Poster
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
Quote:
Originally Posted by scasey View Post
Oh. Then I don't understand your OP at all, I guess. What were you using $HOME as a "convenient abbreviation" for, then?
For my actual home directory of course! Do people usually let everyone and his wife know what name they log on with at home?
 
Old 08-20-2018, 07:38 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
have you tried debugging with say, scp ?
 
Old 08-20-2018, 08:47 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,753

Rep: Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930
Quote:
secure_chroot_dir=/usr/share/vsftpd/empty
What happens if you comment out this directive?
 
Old 08-20-2018, 09:23 AM   #10
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628

Original Poster
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
Quote:
Originally Posted by michaelk View Post
What happens if you comment out "secure_chroot_dir=/usr/share/vsftpd/empty" ?
Then it fails because it looks by default for a directory called /usr/share/empty, which doesn't exist on my system.

@Habitual. I wasn't able to use scp. I got connection refused. Do I have to have an ssh server running on the remote machine to make this work?
 
Old 08-28-2018, 06:34 AM   #11
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628

Original Poster
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
Update: I tried logging in as root and got the same result. I could list files in /home/ftp but not my personal home directory. So it can't be a Unix permissions problem. It must be the vsftpd server itself that is playing up.
 
Old 08-28-2018, 07:54 AM   #12
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,167
Blog Entries: 1

Rep: Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038Reputation: 2038
Quote:
Originally Posted by hazel View Post
Update: I tried logging in as root and got the same result. I could list files in /home/ftp but not my personal home directory. So it can't be a Unix permissions problem. It must be the vsftpd server itself that is playing up.
By default root is not allowed to use ftp, for security reasons.
And you should keep it this way, as data is transmitted unencrypted in ftp protocol.
 
Old 08-28-2018, 09:01 AM   #13
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,333
Blog Entries: 3

Rep: Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729
Quote:
Originally Posted by hazel View Post
I wasn't able to use scp. I got connection refused. Do I have to have an ssh server running on the remote machine to make this work?
Yes. Adding the OpenSSH-server package to your destination machine will allow both scp and SFTP. With the latter you can use Nautilus, Caja, PCManFM, FileZilla, sshfs, and many others, finding a client or two to suit your tastes and work flow. Both scp and SFTP are included and it is enough to install the package and away you go. However, if the service is to be made available over the Internet and not just the LAN, it is a good idea to use SSH keys for authentication and turn off password authentication.

My recommendation is complete removal of the FTP daemon and using SFTP instead.
 
1 members found this post helpful.
Old 08-28-2018, 10:08 AM   #14
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628

Original Poster
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
Quote:
Originally Posted by bathory View Post
By default root is not allowed to use ftp, for security reasons.
And you should keep it this way, as data is transmitted unencrypted in ftp protocol.
I quite agree. It's very bad practice but this was a one-off experiment for the purpose of testing a puzzling situation. Actually I'm surprised I was allowed to log in as root at all; I'm checking now what configuration files I need to prevent this in future (creating an /etc/ftpusers file should do it).

@Turbocapitalist. This is LFS so adding ssh will be easy enough. Do I need to create a certificate to use ssh and its family?

Last edited by hazel; 08-28-2018 at 10:14 AM.
 
Old 08-28-2018, 10:37 AM   #15
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,333
Blog Entries: 3

Rep: Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729Reputation: 3729
Quote:
Originally Posted by hazel View Post
@Turbocapitalist. This is LFS so adding ssh will be easy enough. Do I need to create a certificate to use ssh and its family?
If LFS is like the other distros, the host keys (identifying the SSH host to incoming accounts) will be generated on first use. The individual authentication keys (identifying the incoming accounts to the SSH host) need to be generated manually for each user.

SSH Certificates are similar to SSH Keys, and used in the same way, but I admit to ignorance in their advantages or differences. For SSH keys, use ssh-keygen on the machine you are connecting from:

Code:
ssh-keygen -f ~/.ssh/other_machine_key.rsa -t rsa -b 3072 -C 'hazel from laptop'
ssh-copy-id -i ~/.ssh/other_machine_key.rsa hazel@othermachine.example.com
I show the -f and -C options for ssh-keygen as it is very useful to annotate the individual keys.
 
1 members found this post helpful.
  


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
LXer: Setup FTP server using VsFtp and Configure Secure FTP connections on Ubuntu 14.04 Server LXer Syndicated Linux News 0 08-20-2014 07:00 PM
[SOLVED] FTP Server behind NAT (IPtables) List FTP directories Problem turki_00 Linux - Newbie 5 02-05-2012 08:44 AM
VSFTP Directory Listing Problem noahclark Linux - Server 0 03-20-2008 01:21 PM
setting up FTP server VSFTP sigkill Linux - Server 6 01-21-2008 05:10 AM
how can I restrict ftp users listing files from a pure-ftp server adrianmak Linux - Networking 2 12-31-2002 08:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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