How to create user in CentOS - ChuanyuWang/test GitHub Wiki
Disable password based login before create new user
- Add the following lines in
/etc/ssh/sshd_configfile
ChallengeResponseAuthentication no
PasswordAuthentication no
AuthenticationMethods publickey
PermitEmptyPasswords no
PubkeyAuthentication yes
- Restart sshd service by
service sshd restart
Steps to create new user, e.g. jenkins
- Run
adduser jenkinsas root user - Set password by
passwd jenkins - Switch user by
su jenkins mkdir ~/.sshtouch ~/.ssh/authorized_keys- Copy the public key into file
~/.ssh/authorized_keys - Change permission as below (<==important!!!)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Tips:
- Run
sudo -ito test if current user could runsudo - Switch user by
su username - Enable user with
sudocommand byusermod -aG wheel newadmin