添加用户组
groupadd developer
添加用户并分配组
useradd -g developer developer
设置ssh登录免密码
cd /home/developer/
mkdir .ssh
chown -R developer:developer .ssh
cd .ssh
vi authorized_keys ### 加入公钥
chown developer:developer authorized_keys ### 修改所属用户组,到此就可以用用户名免密码登陆了
禁用密码登录
### 启用ssh验证 若为开启开启
vi /etc/ssh/sshd_config ### 以下三行需要去掉#注释,没有就不用管
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
- 找到
PasswordAuthentication yes
改为no - 重启ssh服务
service sshd restart
普通用户添加root权限
- vi
/etc/sudoers
找到
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
- 后边加入
developer ALL=(ALL) NOPASSWD: ALL
到此基础账户安全体系搭建完毕。
给用户指定shell
- 添加用户指定shell
sudo useradd -s /bin/bash developer
- 修改用户shell
sudo usermod -s /bin/bash developer