Centos限制root用户登录,用户key登录

useradd  litong

mkdir -p /home/litong/.ssh

#上传生成的key:litong.pub

cat  litong.pub >> /home/litong/.ssh/authorized_keys

chown -R litong:litong /home/litong/.ssh

chmod -R go-rwx /home/litong/.ssh

usermod  -a -G  wheel  litong


vim  /etc/ssh/sshd_config

#禁止root登录

PermitRootLogin yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication no

#sudo

vim /etc/sudoers

%wheel  ALL=(ALL)       NOPASSWD: ALL

你可能感兴趣的:(用户登录)