Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasperf/b9fb2c991f830ecd0cfc to your computer and use it in GitHub Desktop.
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
//check if port is in use
netstat -ln |grep 8080
//check what is using this port
netstat -tupln |grep 8080
##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