Last active
August 29, 2015 14:02
-
-
Save jasperf/b9fb2c991f830ecd0cfc to your computer and use it in GitHub Desktop.
Add a (ssh) user to unix or linux server, put the user in sudo users group and chroot the ssh/sftp user to a path of choice so it can only work from a certain directory #centos #chroot #unix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//check if port is in use | |
netstat -ln |grep 8080 | |
//check what is using this port | |
netstat -tupln |grep 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##the following command are done by root or a sudo user | |
useradd <username> | |
passwd <username> | |
## add user to sudo group which could be wheel or sudo depending on your setup | |
usermod -G wheel <username> | |
#Edit sshd_config to chroot the user. Path here below is on Centos or Redhat and with nano editor up and running | |
nano /etc/ssh/sshd_config | |
##add the end of the file add | |
Match User <username> | |
ChrootDirectory /path/of/choice | |
ForceCommand internal-sftp | |
## control X and save | |
service sshd restart | |
##check if the user is listed and has a home directory | |
cat /etc/passwd | grep "/home" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment