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_config
file
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 jenkins
as root user - Set password by
passwd jenkins
- Switch user by
su jenkins
mkdir ~/.ssh
touch ~/.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 -i
to test if current user could runsudo
- Switch user by
su username
- Enable user with
sudo
command byusermod -aG wheel newadmin