跳过正文
  1. Blogs/

SSH Google Authenticator

·323 字·1 分钟· ·
代码 Ssh-Google-Authenticator Ubuntu Google Ssh Two Factor Authenticator
作者
大大的小蜗牛
机会总是垂青于有准备的人!
目录

我经常需要用 SSH 连加家到自己的电脑上,如果单独用密码验证,存在很多安全隐患,如果用密钥,又很麻烦,所以我选择的是用 Google 的双重验证。顺便换了一个非 22 端口。
下面的方法同样适用于 Ubuntu VPS,我的几个 VPS 都是这样设置的。

Ubuntu 16.04.1 LTS 64bit
OpenSSH server

1、安装 SSH 服务
#

sudo apt update
sudo apt install openssh-server

2、安装 Google-Authenticator
#

sudo apt update
sudo apt install libpam-google-authenticator

3、生成密钥
#

google-authenticator

过程中全部按 y

4、配置手机 app
#

Google-Authenticator洋葱Authy身份宝 等扫描上一步生成的二维码即可。
我个人使用的是 Authy。

5、配置
#

sudo vim /etc/pam.d/sshd

添加:

auth required pam_google_authenticator.so

配置:

sudo vim /etc/ssh/sshd_config

修改:

ChallengeResponseAuthentication yes #改为 yes
port 22222 #SSH 默认使用 22 端口,这里看个人喜好修改成其他的或不修改

5、重启 SSH

sudo service ssh restart

使用时,Verification code:输入手机 app 生成的验证码即可。

相关文章

Web 版 SSH Gateone
·608 字·2 分钟
代码 Gateone Nginx Gateone Ssh Web Shell
Oneinstack Nginx 反代 Google
·382 字·1 分钟
代码 Oneinstack-Nginx-Google Google Oneinstack Nginx Proxy
Ubuntu 鼠标加速度
·313 字·1 分钟
代码 Ubuntu-Mouse-Acceleration 鼠标 Ubuntu 加速度 鼠标加速 Xset M 0

LoadGiscusor