<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Configuring sftp with chroot! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/configuring-sftp-with-chroot/m-p/4261898#M734324</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm using the next procedure to configure a sftp+chroot environment for some final users on my hpux box:&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;Title: HP-UX: How to configure a user for SFTP access only, in a chroot'ed environment.&lt;BR /&gt;Document ID: 4000115147&lt;BR /&gt;Last Modified Date: 3/2/06&lt;BR /&gt;&lt;BR /&gt;PROBLEM&lt;BR /&gt;Some users on an HP-UX 11.x system with ssh (Secure Shell) should be&lt;BR /&gt;configured to have SFTP access, but these users should not be able to&lt;BR /&gt;log in through ssh. Instead, these users should be directed to the&lt;BR /&gt;limited environment, often called "chroot'ed" environment.&lt;BR /&gt;&lt;BR /&gt;CONFIGURATION&lt;BR /&gt;Operating System - HP-UX&lt;BR /&gt;Version - 11.x&lt;BR /&gt;Subsystem - ssh&lt;BR /&gt;RESOLUTION&lt;BR /&gt;HOW TO RESTRICT A USER TO ONLY HAVE SFTP ACCESS (NO SSH):&lt;BR /&gt;&lt;BR /&gt;Create the following shell script for the sftp user on the server,&lt;BR /&gt;which you want to deny ssh shell access:&lt;BR /&gt;&lt;BR /&gt;# vi /opt/ssh/etc/sftponly&lt;BR /&gt;#&amp;lt;---------------------- begin script ----------------------&amp;gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;# The shell used here must be /bin/sh&lt;BR /&gt;# Shell arguments must be -c /opt/ssh/libexec/sftp-server&lt;BR /&gt;if [ "$1" != "-c" -o "$2" != "/opt/ssh/libexec/sftp-server" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Error: sftpshell only runs the sftp-server program."&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;shift 2&lt;BR /&gt;/opt/ssh/libexec/sftp-server $*&lt;BR /&gt;#&amp;lt;---------------------- end script ----------------------&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CREATE THE NO-SSH SFTP USER:&lt;BR /&gt;&lt;BR /&gt;1. Adlib from this example by modifying the /etc/passwd file for the&lt;BR /&gt;targeted non-ssh sftp user:&lt;BR /&gt;&lt;BR /&gt;# vi /etc/passwd&lt;BR /&gt;sftpusr:&lt;ENCRYPTED_PW&gt;:101:20:no-ssh sftp only user:/home/sftpusr:\&lt;BR /&gt;/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;2. Next, modify the ownership and permissions to this new shell account.&lt;BR /&gt;&lt;BR /&gt;# chmod 555 /opt/ssh/etc/sftponly&lt;BR /&gt;# chown bin:bin /opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CREATE THE NO-SSH SFTP USER USING A CHROOTED DIRECTORY:&lt;BR /&gt;&lt;BR /&gt;If your user is to have a "chrooted" directory follow these steps:&lt;BR /&gt;&lt;BR /&gt;1. Perform the steps above "CREATE THE NO-SFTP USER".&lt;BR /&gt;&lt;BR /&gt;2. Create/convert the no-ssh sftp user to have a chrooted directory&lt;BR /&gt;by using this setup tool:&lt;BR /&gt;&lt;BR /&gt;# /opt/ssh/ssh_chroot_setup.sh&lt;BR /&gt;&lt;BR /&gt;Now the password entry would look something like this:&lt;BR /&gt;&lt;BR /&gt;sftpuser:&lt;ENCRYPTED_PW&gt;:101:20:chrooted no-ssh sftp user:\&lt;BR /&gt;/newroot/./home/sftpuser:/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;3. Complete these no-ssh chrooted configuration steps:&lt;BR /&gt;&lt;BR /&gt;# mkdir /newroot/opt/ssh/etc&lt;BR /&gt;# chmod 555 /newroot/opt/ssh/etc&lt;BR /&gt;# chown bin:bin /newroot/opt/ssh/etc&lt;BR /&gt;# cp /opt/ssh/etc/sftponly /newroot/opt/ssh/etc&lt;BR /&gt;# chmod 555 /newroot/opt/ssh/etc/sftponly&lt;BR /&gt;# chown bin:bin /newroot/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;Also be sure these permissions are correct:&lt;BR /&gt;&lt;BR /&gt;# chmod 555 /newroot/*&lt;BR /&gt;# chown bin:bin /newroot/*&lt;BR /&gt;# ls -al /newroot&lt;BR /&gt;drwxr-xr-x 10 root sys 8192 Feb 24 09:22 .&lt;BR /&gt;drwxr-xr-x 32 root root 8192 Feb 24 11:55 ..&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 bin&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 dev&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 etc&lt;BR /&gt;dr-xr-xr-x 3 root sys 96 Aug 19 2005 home&lt;BR /&gt;dr-xr-xr-x 3 root sys 96 Aug 19 2005 opt&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 sbin&lt;BR /&gt;dr-xr-xr-x 4 root sys 96 Aug 19 2005 usr&lt;BR /&gt;dr-xr-xr-x 3 root sys 96 Aug 19 2005 var&lt;BR /&gt;&lt;BR /&gt;4. Lastly, test for no shell to ssh and shell-ok for sftp for the&lt;BR /&gt;sftpusr from the client:&lt;BR /&gt;&lt;BR /&gt;$ ssh sftpusr@localhost&lt;BR /&gt;Password:&lt;BR /&gt;Error: sftpshell only runs the sftp-server program.&lt;BR /&gt;Connection to localhost closed.&lt;BR /&gt;&lt;BR /&gt;$ sftp sftpusr@localhost&lt;BR /&gt;Connecting to localhost...&lt;BR /&gt;Password:&lt;BR /&gt;sftp&amp;gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;&lt;BR /&gt;everything work's good after the configuration, but my test user continues leaving his home directory (the chroot doesn´t work). Some idea ???. &lt;BR /&gt;&lt;BR /&gt;I have another questions:&lt;BR /&gt;&lt;BR /&gt;a) What is the configuration file to establish the permissions for the sftp accounts with this configuration ? (like the ftpaccess).&lt;BR /&gt;b) Is possible to configure another file system like home directory for the users accounts ??.&lt;BR /&gt;&lt;BR /&gt;My scenario is the next:&lt;BR /&gt;&lt;BR /&gt;- hpux 11.11&lt;BR /&gt;- T1471AA                       A.05.00.024    HP-UX Secure Shell&lt;BR /&gt;&lt;BR /&gt;Test account:&lt;BR /&gt;&lt;BR /&gt;sftpusr:*:118:20:chrooted user:/newroot/./home/sftpusr:/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;Thank´s in advance.&lt;/ENCRYPTED_PW&gt;&lt;/ENCRYPTED_PW&gt;</description>
    <pubDate>Tue, 02 Sep 2008 15:42:47 GMT</pubDate>
    <dc:creator>Ivan Azuara</dc:creator>
    <dc:date>2008-09-02T15:42:47Z</dc:date>
    <item>
      <title>Configuring sftp with chroot!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/configuring-sftp-with-chroot/m-p/4261898#M734324</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm using the next procedure to configure a sftp+chroot environment for some final users on my hpux box:&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;Title: HP-UX: How to configure a user for SFTP access only, in a chroot'ed environment.&lt;BR /&gt;Document ID: 4000115147&lt;BR /&gt;Last Modified Date: 3/2/06&lt;BR /&gt;&lt;BR /&gt;PROBLEM&lt;BR /&gt;Some users on an HP-UX 11.x system with ssh (Secure Shell) should be&lt;BR /&gt;configured to have SFTP access, but these users should not be able to&lt;BR /&gt;log in through ssh. Instead, these users should be directed to the&lt;BR /&gt;limited environment, often called "chroot'ed" environment.&lt;BR /&gt;&lt;BR /&gt;CONFIGURATION&lt;BR /&gt;Operating System - HP-UX&lt;BR /&gt;Version - 11.x&lt;BR /&gt;Subsystem - ssh&lt;BR /&gt;RESOLUTION&lt;BR /&gt;HOW TO RESTRICT A USER TO ONLY HAVE SFTP ACCESS (NO SSH):&lt;BR /&gt;&lt;BR /&gt;Create the following shell script for the sftp user on the server,&lt;BR /&gt;which you want to deny ssh shell access:&lt;BR /&gt;&lt;BR /&gt;# vi /opt/ssh/etc/sftponly&lt;BR /&gt;#&amp;lt;---------------------- begin script ----------------------&amp;gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;# The shell used here must be /bin/sh&lt;BR /&gt;# Shell arguments must be -c /opt/ssh/libexec/sftp-server&lt;BR /&gt;if [ "$1" != "-c" -o "$2" != "/opt/ssh/libexec/sftp-server" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Error: sftpshell only runs the sftp-server program."&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;shift 2&lt;BR /&gt;/opt/ssh/libexec/sftp-server $*&lt;BR /&gt;#&amp;lt;---------------------- end script ----------------------&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CREATE THE NO-SSH SFTP USER:&lt;BR /&gt;&lt;BR /&gt;1. Adlib from this example by modifying the /etc/passwd file for the&lt;BR /&gt;targeted non-ssh sftp user:&lt;BR /&gt;&lt;BR /&gt;# vi /etc/passwd&lt;BR /&gt;sftpusr:&lt;ENCRYPTED_PW&gt;:101:20:no-ssh sftp only user:/home/sftpusr:\&lt;BR /&gt;/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;2. Next, modify the ownership and permissions to this new shell account.&lt;BR /&gt;&lt;BR /&gt;# chmod 555 /opt/ssh/etc/sftponly&lt;BR /&gt;# chown bin:bin /opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CREATE THE NO-SSH SFTP USER USING A CHROOTED DIRECTORY:&lt;BR /&gt;&lt;BR /&gt;If your user is to have a "chrooted" directory follow these steps:&lt;BR /&gt;&lt;BR /&gt;1. Perform the steps above "CREATE THE NO-SFTP USER".&lt;BR /&gt;&lt;BR /&gt;2. Create/convert the no-ssh sftp user to have a chrooted directory&lt;BR /&gt;by using this setup tool:&lt;BR /&gt;&lt;BR /&gt;# /opt/ssh/ssh_chroot_setup.sh&lt;BR /&gt;&lt;BR /&gt;Now the password entry would look something like this:&lt;BR /&gt;&lt;BR /&gt;sftpuser:&lt;ENCRYPTED_PW&gt;:101:20:chrooted no-ssh sftp user:\&lt;BR /&gt;/newroot/./home/sftpuser:/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;3. Complete these no-ssh chrooted configuration steps:&lt;BR /&gt;&lt;BR /&gt;# mkdir /newroot/opt/ssh/etc&lt;BR /&gt;# chmod 555 /newroot/opt/ssh/etc&lt;BR /&gt;# chown bin:bin /newroot/opt/ssh/etc&lt;BR /&gt;# cp /opt/ssh/etc/sftponly /newroot/opt/ssh/etc&lt;BR /&gt;# chmod 555 /newroot/opt/ssh/etc/sftponly&lt;BR /&gt;# chown bin:bin /newroot/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;Also be sure these permissions are correct:&lt;BR /&gt;&lt;BR /&gt;# chmod 555 /newroot/*&lt;BR /&gt;# chown bin:bin /newroot/*&lt;BR /&gt;# ls -al /newroot&lt;BR /&gt;drwxr-xr-x 10 root sys 8192 Feb 24 09:22 .&lt;BR /&gt;drwxr-xr-x 32 root root 8192 Feb 24 11:55 ..&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 bin&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 dev&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 etc&lt;BR /&gt;dr-xr-xr-x 3 root sys 96 Aug 19 2005 home&lt;BR /&gt;dr-xr-xr-x 3 root sys 96 Aug 19 2005 opt&lt;BR /&gt;dr-xr-xr-x 2 root sys 96 Aug 19 2005 sbin&lt;BR /&gt;dr-xr-xr-x 4 root sys 96 Aug 19 2005 usr&lt;BR /&gt;dr-xr-xr-x 3 root sys 96 Aug 19 2005 var&lt;BR /&gt;&lt;BR /&gt;4. Lastly, test for no shell to ssh and shell-ok for sftp for the&lt;BR /&gt;sftpusr from the client:&lt;BR /&gt;&lt;BR /&gt;$ ssh sftpusr@localhost&lt;BR /&gt;Password:&lt;BR /&gt;Error: sftpshell only runs the sftp-server program.&lt;BR /&gt;Connection to localhost closed.&lt;BR /&gt;&lt;BR /&gt;$ sftp sftpusr@localhost&lt;BR /&gt;Connecting to localhost...&lt;BR /&gt;Password:&lt;BR /&gt;sftp&amp;gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;&lt;BR /&gt;everything work's good after the configuration, but my test user continues leaving his home directory (the chroot doesn´t work). Some idea ???. &lt;BR /&gt;&lt;BR /&gt;I have another questions:&lt;BR /&gt;&lt;BR /&gt;a) What is the configuration file to establish the permissions for the sftp accounts with this configuration ? (like the ftpaccess).&lt;BR /&gt;b) Is possible to configure another file system like home directory for the users accounts ??.&lt;BR /&gt;&lt;BR /&gt;My scenario is the next:&lt;BR /&gt;&lt;BR /&gt;- hpux 11.11&lt;BR /&gt;- T1471AA                       A.05.00.024    HP-UX Secure Shell&lt;BR /&gt;&lt;BR /&gt;Test account:&lt;BR /&gt;&lt;BR /&gt;sftpusr:*:118:20:chrooted user:/newroot/./home/sftpusr:/opt/ssh/etc/sftponly&lt;BR /&gt;&lt;BR /&gt;Thank´s in advance.&lt;/ENCRYPTED_PW&gt;&lt;/ENCRYPTED_PW&gt;</description>
      <pubDate>Tue, 02 Sep 2008 15:42:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/configuring-sftp-with-chroot/m-p/4261898#M734324</guid>
      <dc:creator>Ivan Azuara</dc:creator>
      <dc:date>2008-09-02T15:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Configuring sftp with chroot!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/configuring-sftp-with-chroot/m-p/4261899#M734325</link>
      <description>Ivan&lt;BR /&gt;Here are my notes on how to set up a chroot'd sftponly account.  I hope this helps.&lt;BR /&gt;&lt;BR /&gt;A.05.00.025    HP-UX Secure Shell&lt;BR /&gt;&lt;BR /&gt;====================================&lt;BR /&gt;To set up chrooted ssh only&lt;BR /&gt;=================&lt;BR /&gt;The goal here is to have a sftp dedicated account where outside access is&lt;BR /&gt;limtited to sftp connections.  All successful sftp connections will be&lt;BR /&gt;confined to a root jail.&lt;BR /&gt;&lt;BR /&gt;Create user:&lt;BR /&gt;   uadd -u 151 -d /home/sftpxfr -s /bin/sh -c "chrooted user" sftpxfr&lt;BR /&gt;&lt;BR /&gt;mkdir /home/sfpxfr&lt;BR /&gt;chown sftpxfr:ftp /home/sftpxfr&lt;BR /&gt;chmod 755 /home/sftpxfr&lt;BR /&gt;&lt;BR /&gt;set password for this user and set up security settngs.&lt;BR /&gt;&lt;BR /&gt;Set up ssh auto-authentication.&lt;BR /&gt;su - sftpxfr&lt;BR /&gt;mkdir .ssh&lt;BR /&gt;cd .ssh&lt;BR /&gt;vi authorized_keys&lt;BR /&gt;        Add keys as necessary&lt;BR /&gt;cd ..&lt;BR /&gt;chmod 700 .ssh&lt;BR /&gt;&lt;BR /&gt;Test with ssh sftpxfr@servername from another box.&lt;BR /&gt;&lt;BR /&gt;Run setup script /opt/ssh/utils/ssh_chroot_setup.sh . Select option 1 and use&lt;BR /&gt;chroot directory /newroot&lt;BR /&gt;&lt;BR /&gt;Create /newroot/tmp  directory&lt;BR /&gt;mkdir /newroot/tmp ; chmod 1777 /newroot/tmp&lt;BR /&gt;&lt;BR /&gt;cd /newroot/opt/ssh&lt;BR /&gt;cp -pr /opt/ssh/utils .&lt;BR /&gt;&lt;BR /&gt;In /opt/ssh/etc/sshd_config add to the end :&lt;BR /&gt;Match User sftpxfr&lt;BR /&gt;      ChrootDirectory /newroot&lt;BR /&gt;&lt;BR /&gt;Restart secsh&lt;BR /&gt;/sbin/init.d/secsh stop ; sleep 2 ; /sbin/init.d/secsh start&lt;BR /&gt;&lt;BR /&gt;Update /newroot/etc/passwd&lt;BR /&gt;        Remove all lines except chroot account entry.&lt;BR /&gt;        sftpxfr:*:151:203:chrooted user:/home/sftpxfr:/bin/sh&lt;BR /&gt;&lt;BR /&gt;Update /etc/password and update shell to sftponly&lt;BR /&gt; sftpxfr:*:151:203:chrooted user:/home/sftpxfr:/opt/ssh/utils/sftponly&lt;BR /&gt;&lt;BR /&gt;Allow sftpxfr permission to write to /newroot/home/sftpxfr&lt;BR /&gt;        chown sftpxfr:ftp /newroot/home/sftpxfr&lt;BR /&gt;&lt;BR /&gt;Confirm that:&lt;BR /&gt;  -auto-authentication works for sftp&lt;BR /&gt;  -ssh to sftpxfr fails&lt;BR /&gt;  -that sftpxfr user can not see beyond the contents of /newroot.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Tue, 16 Sep 2008 15:34:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/configuring-sftp-with-chroot/m-p/4261899#M734325</guid>
      <dc:creator>John C. Polhemus</dc:creator>
      <dc:date>2008-09-16T15:34:50Z</dc:date>
    </item>
  </channel>
</rss>

