[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 135
  • Last Modified:

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

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
Nitsan Reznik
Asked:
Nitsan Reznik
  • 8
  • 7
1 Solution
 
gheistCommented:
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
 
Nitsan ReznikIT Consultant Author Commented:
Hi,

Thank you for you comment.

so in my example, do I need to change something?
I will see the logs as well.
0
 
gheistCommented:
See the log please.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Nitsan ReznikIT Consultant Author Commented:
Tried searching for any logs in /var/log/secure but no logs appear there.
0
 
gheistCommented:
            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
 
Nitsan ReznikIT Consultant Author Commented:
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
 
gheistCommented:
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
 
Nitsan ReznikIT Consultant Author Commented:
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
 
Nitsan ReznikIT Consultant Author Commented:
Any other idea? Maybe because I'm mounting the new home to a NAS box?
0
 
gheistCommented:
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
 
Nitsan ReznikIT Consultant Author Commented:
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
 
gheistCommented:
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
 
Nitsan ReznikIT Consultant Author Commented:
Hi,

I did it but, still cannot write as the user logged-on.
0
 
Nitsan ReznikIT Consultant Author Commented:
I ended up installing a new SFTP on a new server with physical drives. Thank you for your time to answer my questions.
0
 
gheistCommented:
NFS and iSCSI will work for you.
1

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now