美文网首页
ubuntu 16.04 ssh 登录添加 Google Aut

ubuntu 16.04 ssh 登录添加 Google Aut

作者: 春秋不做梦 | 来源:发表于2021-07-05 09:50 被阅读0次

安装 Google Authenticator

$ sudo apt install libpam-google-authenticator

安装完成之后修改文件 /etc/pam.d/sshd ,在此文件末尾添加

$ sudo vi /etc/pam.d/sshd
auth required pam_google_authenticator.so
####没有开启两部验证的账号还可以登录,添加nullok
auth required pam_google_authenticator.so nullok

修改sshd配置文件

#no修改为yes
ChallengeResponseAuthentication yes

重启ssh服务

sudo systemctl restart sshd

来生成一个二维码和密匙,全部选择yes

$ google-authenticator

通过扫描二维码或者输入密匙添加到 Google Authenticator App,接下来登录时在输入密码的同时还需要输入谷歌验证中的验证码(手机提前安装好Google Authenticator App https://google-authenticator.en.softonic.com/android)

ssh ubuntu@<ip>
Verification code:
Password:
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-142-generic x86_64)

相关文章

网友评论

      本文标题:ubuntu 16.04 ssh 登录添加 Google Aut

      本文链接:https://www.haomeiwen.com/subject/vbhkultx.html