流程
在Ubuntu安装google-authenticator:运行
“sudo apt-get install libpam-google-authenticator”。手机安装google-authenticator。
Ubuntu生成二维码 ,详情见附录1
设置Ubuntu登陆时加载google-authenticator:运行“sudo vi /etc/pam.d/sshd”,在最后加一行“auth required pam_google_authenticator.so”;
运行“sudo vi /etc/ssh/sshd_config”,
找到“ChallengeResponseAuthentication”这行,
改成“ChallengeResponseAuthentication yes”。重启SSH:“sudo service ssh restart”。
- 再次登陆时,输入帐号密码登陆之外,还要输入google-authenticator的6位验证码。
附录1,:生成二维码(过程中需访问google)
google-authenticator #运行此命令
Do you want authentication tokens to be time-based (y/n) y #提示是否要基于时间生成令牌,选择y