Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active August 17, 2018 14:51
Show Gist options
  • Save JeOam/b23fe7e67676fdf27b39 to your computer and use it in GitHub Desktop.
Save JeOam/b23fe7e67676fdf27b39 to your computer and use it in GitHub Desktop.
VPS notes

#####从零开始配置 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment