-->
yum install gcc
--------------------------------------------------------------------------------------------------------------------------------------
cd /tmp
mkdir -p /opt/zlib
mkdir zlib1.25
cd zlib1.25/
wget http://zlib.net/zlib125.zip
unzip zlib125.zip
make
make install prefix=/opt/zlib/
--------------------------------------------------------------------------------------------------------------------------------------
The make commands here take forever to run. If the 'make test' command returns any errors, you will need to fix them before continuing.
--------------------------------------------------------------------------------------------------------------------------------------
cd /tmp
mkdir -p /opt/openssl
wget http://www.openssl.org/source/openssl-1.0.0e.tar.gz
tar xvzf openssl-1.0.0e.tar.gz
cd openssl-1.0.0e
./config --prefix=/opt/openssl --openssldir=/opt/openssl
make
make test
make install
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
cd /tmp
mkdir -p /opt/openssh
wget http://mirror.team-cymru.org/pub/OpenBSD/OpenSSH/portable/openssh-5.9p1.tar.gz
tar xvzf openssh-5.9p1.tar.gz
cd openssh-5.9p1
--------------------------------------------------------------------------------------------------------------------------------------
Some of these commands make take some time to run. Go grab a coke.
REMEMBER: This tutorial is meant for setting up a server for the first time. You may need to copy your sshd_config file (or at least the directives you want to keep) from /etc/ssh to save your old settings.
--------------------------------------------------------------------------------------------------------------------------------------
./configure --prefix=/opt/openssh --with-ssl-dir=/opt/openssl --with-xauth=/usr/X11R6/bin/xauth --with-zlib=/opt/zlib
make
make install
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
# Some functions to make the below more readable
KEYGEN=/opt/openssh/bin/ssh-keygen
SSHD=/opt/openssh/sbin/sshd
RSA1_KEY=/opt/openssh/etc/ssh_host_key
RSA_KEY=/opt/openssh/etc/ssh_host_rsa_key
DSA_KEY=/opt/openssh/etc/ssh_host_dsa_key
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
/etc/init.d/sshd restart
telnet localhost 22
--------------------------------------------------------------------------------------------------------------------------------------
The telnet command should return some lines looking like this:
You need to be sure that the last line includes the "OpenSSH_5.9" to confirm that it is the version we just installed.
--------------------------------------------------------------------------------------------------------------------------------------
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
SSH-2.0-OpenSSH_5.9
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
Subsystem sftp internal-sftp
--------------------------------------------------------------------------------------------------------------------------------------
Also add (at the bottom of the file) the following lines
--------------------------------------------------------------------------------------------------------------------------------------
Match Group sftponly
ChrootDirectory /home/%u
ForceCommand internal-sftp
AllowTcpForwarding no
Now, all users added to the 'sftponly' group will be jailed to their home directory.
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
groupadd sftponly
chown root:root /home
chmod 755 /home
--------------------------------------------------------------------------------------------------------------------------------------
Now when you create users that need to be jailed, make sure they belong to the 'sftponly' group. For the user "mark" with the password "test", you will need to do the folling steps.
--------------------------------------------------------------------------------------------------------------------------------------
useradd mark
usermod -g sftponly mark
usermod -s /bin/false mark
usermod -d /home/mark mark
passwd mark
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
chmod 755 /home/mark
chown root:root /home/mark
mkdir /home/mark/public_html
chown mark:sftponly /home/mark/public_html
--------------------------------------------------------------------------------------------------------------------------------------
Try to log in as mark through putty (or any ssh terminal). You should get some sort of error involving an abort or denied access.
(optinal for ftp users )
Install vsftpd
#yum install vsftpd
Now it is done