ubuntu 16.04 ssh 登录添加 Google Authenticator 两步验证

安装 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)
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容