RHEL5.5 configure SFTP-ONLY to access RHEL with SSH remote access is recommended, but sometimes we only want users to access files on the server, but cannot log on to the server for operations, that is, cannot SSH Login, however, SFTP can be used for file transmission. The following configuration can be used for control. If you want to control the sftp directory, you need openssh 4.8p1 or above. If the version is low, reinstall it as follows: http://ftp.jaist.ac.jp/pub/openbsd/openssh/portable/javassshversion
1. Configure the telnet connection. If you reinstall ssh, you need to use telnet to remotely (vnc also works) to view the installed telnet
Set telnet disable to no
Configure telnet to allow root login, comment out pam_securetty.so this line www.2cto.com
Restart the telnet Service
2. log on to the server via telnet and stop ssh
View the original openssh installation status
Uninstall all
3, install the latest version of openssh, this article uses openssh-6.0p1 # cdopenssh-6.0p1 #. /configure -- prefix =/usr/local/ssh -- sysconfdir =/etc/ssh -- with-pam -- with-zlib -- with-ssl-dir =/usr/local/ssl -- with-md5-passwords -- mandir =/usr/share/man # make # makeinstall # cp/usr/local/ssh/bin/*/usr/bin/# cp/usr/local/ssh/ sbin/*/usr/sbin/verify the installation result
Add ssh to the startup service and configure startup
After the ssh installation is complete, stop telnet and return to the ssh remote connection.
4. For example, if you want to use the/work/git/gitspace directory as the root directory for sftp access and control that users can only access files through sftp, but cannot log on via ssh, the configuration is as follows. Create a user group sftp-only www.2cto.com
Specify sftpadmin as the sftp-only group and shell as/sbin/nologin.
Configure ssh so that users in the sftp-only user group can only allow sftp and the root directory is/work/git/gitspace # vi/etc/ssh/sshd_config. Modify the Subsystem section as follows:
Restart the ssh service and use the sftpadmin user to log in and try. Author laizhenhai88