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
相關文章
相關標籤/搜索