#####从零开始配置 Ansible 控制 VPS
#####准备: 首先,手上有一台新安装的 Ubuntu 14.04, 设置 ssh 登录所需
$ cd ~/.ssh
$ ssh-keygen -t rsa -C “remark”
# 添加好新产生 `.pub` 文件到 VPS 后,删除这个 `.pub`
$ rm newfile.pub
VPS 上禁止用密码登录:
sudo vi /etc/ssh/sshd_config
...
The following settings should be set to no:
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
...
sudo service ssh reload
测试是否禁止成功:
ssh root@vps-ip -o PubkeyAuthentication=no
返回:
Permission denied (publickey).
代表已经禁止成功了。
Ref: Generate a ssh key and disable password authentication on the Ubuntu 12.04 (Precise Pangolin) server