Ubuntu禁用root账号,开启Ubuntu密钥登录

新建普通用户

## 新建普通用户
$ adduser ubuntu
$ apt-get install sudo
## 将用户加入sudo组
$ usermod -a -G sudo ubuntu

为普通用户添加公钥

$ su ubuntu
$ mkdir -p ~/.ssh
$ cd ~/.ssh
## 添加公钥
$ touch authorized_keys
$ cat '你的公钥字符串' >> authorized_keys

$ chmod 600 authorized_keys
$ chmod 700 ~/.ssh

设置 SSH,打开密钥登录

$ vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes

## 禁用root账号登录
PermitRootLogin no
## 禁用密码登录
PasswordAuthentication no

$ service sshd restart

猜你喜欢

转载自www.cnblogs.com/gcdd/p/12292376.html