Solved

Non root SFTP users cannot log in - Software caused connection abort

Posted on 2016-10-27
15
111 Views
Last Modified: 2016-10-28
Hi Guys,

We currently use our Linux (Centos 7.2) SSH and we restrict SFTP users to their home directories using chroot jail. Currently all the home folders for the SFTP users are under /home mount point are able to log in properly to each one of their home folder (SFTPWRITE) and cannot see any other folders.

Below is our current config from /etc/ssh/sshd_config:

# override default of no subsystems
# Subsystem     sftp    /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTcpForwarding no


We are using the following commands to create and users & group :

useradd temp01 -g sftponly -s /bin/false
passwd temp01

After creating the user and link him to the group, below command we use to make jailed home dir:


mkdir /home/temp01/SFTPWRITE
chown root /home/temp01
chmod 755 /home/temp01
chown temp01 /home/temp01/SFTPWRITE
chmod 755 /home/temp01/SFTPWRITE


after that we run the following command: setsebool -P ssh_chroot_rw_homedirs on
like I mentioned above, everything works perfectly fine.

The problem has began when we had to create a new mount point /sftphome as opposed to /home due to disk space issues and we followed exactly the same procedures like above just created a new username (temp02) and changed the /home folder to /sftphome  

useradd temp02 -g sftponly -s /bin/false
passwd temp02

mkdir /sftphome/temp02/SFTPWRITE
chown root /sftphome/temp02
chmod 755 /sftphome/temp02
chown temp02 /sftphome/temp02/SFTPWRITE
chmod 755 /sftphome/temp02/SFTPWRITE

Run the command: setsebool -P ssh_chroot_rw_homedirs on

However, when user temp02 attempts to access the SFTP sever eaither via Fila-zilla or winscp, he keeps getting the following error:
Software caused connection abort, Authentication Failed (Please find attached screenshot). I'm able to log in successfully using root.

I have tried changing ChrootDirectory %h to ChrootDirectory /sftphome without any luck.
It would be great if someone has any clue why non root users cannot access where the only difference we did was to create a new mount point for their home folders. Maybe I am missing something here.

Any help will be much appreciated Guys!
2016-10-27_15-57-05.jpg
0
Comment
Question by:Nitsan Reznik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 62

Expert Comment

by:gheist
ID: 41862869
internal-sftp will not chroot to a directory that can be modified by other user.

if users home is /home/x
You need to make symlink in /home called home, so that in /home chroot login can find home directory

/var/log/secure has record of ssh denials.
0
 

Author Comment

by:Nitsan Reznik
ID: 41862903
Hi,

Thank you for you comment.

so in my example, do I need to change something?
I will see the logs as well.
0
 
LVL 62

Expert Comment

by:gheist
ID: 41862914
See the log please.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Nitsan Reznik
ID: 41862918
Tried searching for any logs in /var/log/secure but no logs appear there.
0
 
LVL 62

Expert Comment

by:gheist
ID: 41862936
            In the special case when only sftp is used, not ssh nor scp, it is possible to use ChrootDirectory %h or ChrootDirectory /some/path/%u. The file system containing this directory must be mounted with options nodev and either nosuid or noexec. The owner
             of the directory should be the user. The ownership of the other components of the path must fulfill the usual conditions. No aditional files are required to be present in the directory.

remount new home with nosuid and it will start to work.
0
 

Author Comment

by:Nitsan Reznik
ID: 41862966
Thank you for your help here!

Apologies if I'm being silly here but, in my case, what should be the commands to remount with nosuid and nodev?
0
 
LVL 62

Expert Comment

by:gheist
ID: 41862986
man mount
man fstab

in fstab there is a field says
defaults
make it:
defaults,nosuid,nodev
(that is for the home2, dont try this at / /use or anything that system executables are in)
0
 

Author Comment

by:Nitsan Reznik
ID: 41862996
Thanks I remounted using nosuid and nodev but still cannot access with a SFTP user.

Below is my /etc/fstab

//10.101.77.8/SFTPData  /sftphome               cifs    domain=10.101.77.8,username=FTPAdmin,password=*********,nodev,nosuid 0 0

is that correct?
0
 

Author Comment

by:Nitsan Reznik
ID: 41863031
Any other idea? Maybe because I'm mounting the new home to a NAS box?
0
 
LVL 62

Expert Comment

by:gheist
ID: 41863378
I think cifs mount does not support multiple users or chmod....
Can you make it NFS?

My /var/log/secure is well filled with messages.
You really need to get logs to track login issues. Guessing will not help.
Maybe this?
https://help.ubuntu.com/community/SSH/OpenSSH/Configuring#Log_More_Information
0
 

Author Comment

by:Nitsan Reznik
ID: 41863484
I have been progressing with this and after typing the following command: usermod temp02 -d /sftphome/temp02 , I can finally access and can only see my SFTPWRITE folder however, I am getting the following error: open for write: permission denied (See attached screenshot).
 when trying to upload any file to the SFTPWRITE folder.
I have checked and I cannot make the NAS as NFS as it only supports SMB and SMB2.
2016-10-28_08-53-15.jpg
0
 
LVL 62

Expert Comment

by:gheist
ID: 41863755
CIFS is a single-user filesystem in UNIX's understanding.
All files on mount are root:root 0755
You need something with proper multi-user permissions.
0
 

Author Comment

by:Nitsan Reznik
ID: 41863849
Hi,

I did it but, still cannot write as the user logged-on.
0
 

Author Comment

by:Nitsan Reznik
ID: 41864214
I ended up installing a new SFTP on a new server with physical drives. Thank you for your time to answer my questions.
0
 
LVL 62

Accepted Solution

by:
gheist earned 500 total points
ID: 41864219
NFS and iSCSI will work for you.
1

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question