牙齿痒是什么原因| 从从容容的意思是什么| 为什么一进去就想射| 艾滋病皮肤有什么症状| 骨赘形成是什么意思| hpv是什么意思| 抖是什么生肖| 佛法是什么意思| 擎什么意思| 鼠妇是什么动物| 身上起红疹是什么原因| 房产证和土地证有什么区别| 甘蔗什么时候成熟| 宝宝大便酸臭味是什么原因| 肺部条索灶是什么意思| 女人腿肿应该检查什么| 榴莲有什么好处| 阿咖酚散是什么| 什么是法西斯主义| 咯痰是什么意思| 男生的蛋蛋长什么样| 雌性激素是什么| 脚踝肿是什么病| 日单是什么意思| 月经量少什么原因| 女人胃寒吃什么好得快| 阑尾炎什么症状表现| 头痛眼睛痛什么原因引起的| 为什么水能灭火| 世界上最大的鸟是什么鸟| 甲状腺阳性是什么意思| 明年什么生肖| 云是什么生肖| 便秘吃什么食物| 四大是什么| 白细胞是什么| 蛋白粉什么时候吃| 父亲送什么礼物| 19岁属什么生肖| 尿液发黄什么原因| 怀孕初期应该注意什么| e2是什么意思| 散瞳是什么| 健身吃蛋白粉有什么好处和坏处| 吃什么生发| 宝贝是什么意思| 什么是格言| 月经腰疼是什么原因引起的| 什么地什么| 结婚20年是什么婚姻| 泳字五行属什么| 指数是什么| 十五年是什么婚| 男人小腹疼痛是什么原因| mc什么意思| 黑芝麻和白芝麻有什么区别| 五月21号是什么星座| 草字头下面一个高字读什么| 为什么单位不愿意申请工伤| 刘璋和刘备什么关系| 冬至下雨有什么说法| 96345是什么电话| 魈是什么意思| 夏天穿什么鞋子| 甘油三酯高吃什么食物降得快| 古代人用什么刷牙| 女人梦见下雪是什么征兆| 心衰为什么会引起水肿| dr胸部正位片是检查什么的| 鞠婧祎什么学历| 奈我何是什么意思| 蓝颜知己什么意思| 11月17日什么星座| 国家电网是什么编制| 烧心什么感觉| fl是什么意思| 林彪为什么要叛逃| 皮肤黑吃什么会变白| 白玫瑰花语是什么| 老而弥坚是什么意思| 排卵期过后是什么期| 小针刀是什么| 1940年中国发生了什么| 阴唇为什么一个大一个小| 六点半是什么时辰| 84年属鼠是什么命| 什么是化学性肝损伤| 九月初四是什么星座| 小猫打什么疫苗| 牙冠是什么| 开飞机需要什么驾照| 洛五行属性是什么| 火字旁的有什么字| 感统失调是什么意思| 衍生物是什么意思| 草字头加个弓念什么| 8月27号是什么星座| 咖喱是什么东西| 宝宝什么时候长牙| 什么水果败火| 女性白带有血丝是什么原因| 乳腺结节不能吃什么食物| 剖腹产什么时候可以洗澡| 什么牌子的空调好用又省电| 南瓜什么季节成熟| 寻常疣是什么样子图片| 面筋是什么做的| 鼻子疼是什么原因| 冬天手脚冰凉是什么原因怎么调理| 男人壮阳吃什么最快| 喝啤酒不能吃什么| 脚脱皮什么原因| 什么东西只进不出| 狐臭什么味道| 59岁属什么| 芭乐是什么意思| 天津是什么省| 朝三暮四是什么生肖| 开理疗店需要什么证件| 胃痛按什么部位可以缓解疼痛| 暹什么意思| 白细胞中性粒细胞高是什么原因| 午时右眼跳是什么预兆| 均质是什么意思| 仓鼠吃什么东西| 长期拉肚子是怎么回事什么原因造成| 醉酒第二天吃什么才能缓解难受| 后背一推就出痧是什么原因| 看肾挂什么科| 银河系的中心是什么| 举什么什么举| 口臭吃什么药| 副县长是什么级别| 为什么大拇指只有两节| 佳偶天成什么意思| 黑头是什么| gucci中文叫什么牌子| 身上起红疙瘩是什么原因| 一直不来月经是什么原因| emma什么意思| 功能性子宫出血是什么原因造成的| 新生儿dha什么时候开始吃| r值是什么| feno是什么检查| 甲状腺腺体回声欠均匀是什么意思| 骨头是什么垃圾| moss是什么意思| 喜欢紫色代表什么| 化学性肝损伤是什么意思| 口腔溃疡要吃什么药| 什么水果是碱性的| 7.28是什么星座| 人民币用什么材料做的| 什么叫稽留流产| 血压高吃什么菜和水果能降血压| 腋下属于什么科| 心动过缓吃什么药| 孤单的我还是没有改变是什么歌| 小孩掉头发是什么原因引起的| 跑步后尿血是什么情况| 胃溃疡a2期是什么意思| 喉咙痛可以吃什么| 乌龟一般吃什么东西| 皮疹用什么药| 血性是什么意思| 牙痛吃什么药| no是什么气体| 吩咐是什么意思| 见什么知什么| st是什么意思| 茶苯海明片是什么药| 压马路是什么意思| 复方什么意思| op什么意思| 吃西红柿有什么好处| 11.5是什么星座| 蚯蚓可以钓什么鱼| 色弱是什么意思| 斯德哥尔摩综合症是什么意思| 做梦梦见剪头发是什么意思| 十年结婚是什么婚| dha孕妇什么时候吃| 小猫什么时候打疫苗| 肠道长息肉是什么原因造成的| 平安夜送女朋友什么| 观音菩萨属什么生肖| 手指麻木是什么原因引起的| 脚臭用什么药最好| 蠼螋吃什么| 非萎缩性胃炎是什么意思| 男生为什么要做包皮手术| 天无二日指什么生肖| 为什么经常口腔溃疡| 囫囵吞枣是什么意思| 空气净化器有什么作用| 腕管综合症吃什么药| 弟弟的孩子叫什么| 团长是什么军衔| 屁很臭是什么原因| 哈喇子是什么意思| 肚子胀什么原因| 一丘之貉是什么意思| 窦性心律逆钟向转位是什么意思| 舌头疼吃什么药好得快| 焦虑抑郁吃什么药| 神采什么什么| 上午九点是什么时辰| 7月29号是什么星座| 三拜九叩是什么意思| 毛孔大什么原因形成的| 九八年属什么生肖| 孟母三迁的故事告诉我们什么道理| 七喜是什么饮料| 鸡伸脖子张嘴用什么药| 低聚果糖是什么东西| 晕菜是什么意思| 炖牛肉放什么佐料| 眼角发痒用什么眼药水| 头发掉的厉害是什么原因| 境内是什么意思| 嗯呢什么意思| 什么水果对嗓子好| 好马不吃回头草是什么意思| 阴历7月22是什么日子| 什么辕什么辙| 心电监护pr是什么意思| 女人吃什么| 鸡精吃多了有什么危害| 什么的脊背| 梦到自己生病了什么意思| 维生素D有什么食物| 玛丽珍鞋是什么意思| 铮字五行属什么| 更年期失眠吃什么药效果好| 孕妇白细胞高是什么原因| 曼波是什么意思| hds是什么意思| 文化大革命什么时候| 头晕恶心挂什么科| 乐不思蜀是什么意思| 时迁的绰号是什么| hmg是什么药| 下焦湿热是什么意思| 小弟一阵阵的疼什么原因| 芙蕖是什么意思| 中线是什么意思| 月季什么时候扦插最好| 壬申日是什么意思| 水瓶座和什么座最配| 喝什么能解酒| 头皮发紧是什么病的前兆| 面部填充用什么填充效果好| 低烧吃什么| pls是什么意思| 护肝喝什么茶| 睡美人叫什么名字| 现在的节气是什么| 女人更年期吃什么药| 1984年属鼠五行属什么| 纷呈是什么意思| 嗣女是什么意思| 蝉是什么| 贝兄念什么| sobranie是什么烟| 百度
Jump to content

上海铁路局关于2017年4月21日旅客列车调整运行的公告

From ArchWiki

Google Authenticator provides a two-step authentication procedure using one-time passcodes (OTP), initially standardized by the Initiative for Open Authentication (OATH). The authentication mechanism integrates into the Linux PAM system. This guide shows the installation and configuration of this mechanism.

For the reverse operation (generating codes compatible with Google Authenticator under Linux) see #Code generation below.

Installation

Install the libpam-google-authenticator package, which provides the client program google-authenticator(1) and the PAM module pam_google_authenticator.so. The development version is available with google-authenticator-libpam-gitAUR.

Configuration

This section covers configuring the system's PAM to require Google Authenticator OTP authentication for SSH and, optionally, desktop login.

Note: It is required to generate a secret key file for the complete configuration. Consider generating it before editing (and therefore applying) the PAM configuration.

SSH

Warning: If you do all configuration via SSH do not close the session before you tested that everything is working, else you may lock yourself out.

Usually one demands two-pass authentication only for remote login. The corresponding PAM configuration file is /etc/pam.d/sshd. In case you want to use Google Authenticator globally you would need to change /etc/pam.d/system-auth, however, in this case proceed with extreme caution to not lock yourself out. In this guide we proceed with editing /etc/pam.d/sshd which is most safely (but not necessarily) done in a local session.

To enter both, your unix password and your OTP, add pam_google_authenticator.so above the system-remote-login lines to /etc/pam.d/sshd:

auth            required        pam_google_authenticator.so
auth            include         system-remote-login
account         include         system-remote-login
password        include         system-remote-login
session         include         system-remote-login

This will ask for the OTP before prompting for your Unix password. Changing the order of the two modules will reverse this order.

Warning: Only users that have generated a secret key file (see below) will be allowed to log in using SSH.

To allow login with either the OTP or your Unix password use:

auth            sufficient      pam_google_authenticator.so

Enable keyboard interactive authentication in /etc/ssh/sshd_config.d/99-archlinux.conf:

KbdInteractiveAuthentication yes

Finally, reload sshd.service.

Warning: OpenSSH will ignore all of this if you are authenticating with a SSH-key pair and have disabled password logins. However, as of OpenSSH 6.2, you can add AuthenticationMethods to allow both: two-factor and key-based authentication. See OpenSSH#Two-factor authentication and public keys.

Request OTP only when connecting from outside your local network

Sometimes, we just want to enable the 2FA capability just when we connect from outside our local network. To achieve this, create a file (e.g. /etc/security/access-local.conf) and add the networks where you want to be able to bypass the 2FA from:

# only allow from local IP range
+ : ALL : 192.168.20.0/24
# Additional network: VPN tunnel ip range (in case you have one)
+ : ALL : 10.8.0.0/24
+ : ALL : LOCAL
- : ALL : ALL

Then edit your /etc/pam.d/sshd and add the line:

#%PAM-1.0
auth [success=1 default=ignore] pam_access.so accessfile=/etc/security/access-local.conf
auth      required  pam_google_authenticator.so
auth      include   system-remote-login
account   include   system-remote-login
password  include   system-remote-login
session   include   system-remote-login

Desktop logins

Warning: Do not log out of the session before testing the result on another console.

The Google Authenticator PAM plugin can also be used for console logins and with GDM. Just add the following to /etc/pam.d/login or the /etc/pam.d/gdm-password file:

auth required pam_google_authenticator.so

Usage

Every user who wants to use two-pass authentication needs to

  • generate a secret key file in their home folder, and
  • setup their OTP generators accordingly

Generating a secret key file

Tip: Install qrencode to generate a scannable QR. Scan the QR with the authenticator app to automatically configure the key.

The google-authenticator generates a TOTP secret key file as follows:

$ google-authenticator
Do you want authentication tokens to be time-based (y/n) y
generated_QR_code_here
Your new secret key is: ZVZG5UZU4D7MY4DH
Your verification code is 269371
Your emergency scratch codes are:
  70058954
  97277505
  99684896
  56514332
  82717798

Do you want me to update your "/home/username/.google_authenticator" file (y/n) y

Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y

By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) n

If the computer that you are logging into is not hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y

It is recommended to store the emergency scratch codes safely (print them out and keep them in a safe location) as they are your only way to log in (via SSH) when you lost your mobile phone (i.e. your OTP-generator). They are also stored in ~/.google_authenticator, so you can look them up any time as long as you are logged in.

Storage location

If you want to change the secret key files' storage path, you can use the flag --secret:

$ google-authenticator --secret="/path_folder/username"

Then, do not forget to change the location path for PAM, in /etc/pam.d/sshd:

/etc/pam.d/sshd
auth required pam_google_authenticator.so user=root secret=/path_folder/${USER}

user=root is used to force PAM to search the file using root user.

Also, take care with the permissions of the secret key file. Indeed, the file must be only-readable by the owner (chmod: 400). Here, the owner is root.

$ chown root:root /path_file/secret_key_files
$ chmod 400 /path_file/secret_key_files

Code generation

In the final setup step, each user has to associate the secret key file generated in their home directory with their choice of OTP-generators to serve the authentication codes. A user may set up generators on different devices for redundancy, for example in an OTP application on a mobile phone and a separate password manager, or decide to rely on the emergency scratch codes generated earlier as backup.

Mobile phone generators

Install a generator application on your mobile phone (e.g.):

In the mobile application, create a new account and either scan the QR code from the URL you were told when generating the secret key file, or enter the secret key (in the example above 'ZVZG5UZU4D7MY4DH') manually.

Now you should see a new passcode token being generated every 30 seconds on your phone.

If you have Google Authenticator configured with other systems, then losing your device can prevent you from being able to log in to those systems. Having additional ways to generate the codes can be helpful.

Code managers

A script that enables the display, generation, storage and management of Google Authenticator codes is provided by gashellAUR. An alternative option is auther-gitAUR.

KeePassXC

GUI password manager keepassxc allows associating Google Authenticator codes to its entries, and then it can generate OTP codes and export its keys via QR code.

Command line

The easiest way to generate codes is with oathtool(1). It is available in the oath-toolkit package, and can be used as follows:

$ oathtool --totp --base32 secret_key

On most Android systems with sufficient user access, the Google Authenticator database can be copied off the device and accessed directly, as it is an sqlite3 database. However, at some point in July 2022, the secret column on the accounts table started using encryption. If your database backup does not use this encryption, this shell script will read a Google Authenticator database and generate live codes for each key found:

google-authenticator.sh
#!/bin/sh

# This is the path to the Google Authenticator app file.  It is typically
# located in /data under Android.  Copy it to your PC in a safe location and
# specify the path to it here.
DB="/path/to/com.google.android.apps.authenticator/databases/databases"

sqlite3 "$DB" 'SELECT email,secret FROM accounts;' | while read A
do
        NAME=`echo "$A" | cut -d '|' -f 1`
        KEY=`echo "$A" | cut -d '|' -f 2`
        CODE=`oathtool --totp -b "$KEY"`
        echo -e "\e[1;32m$CODE\e[0m - \e[1;33m$NAME\e[0m"
done

Testing

SSH to your host from another machine and/or from another terminal window:

$ ssh hostname
login as: username
Verification code: generated/backup_code
Password: password
$
tasty是什么意思 阴道炎应该吃什么药 待定是什么意思 白带正常是什么样子 腹部淋巴结肿大是什么原因
勇气是什么 榴莲什么样的好 农历9月17日是什么星座 艾灰有什么作用和功效 脚底板疼是什么原因
什么样的降落伞 教师节给老师送什么礼物 急性胆囊炎吃什么药 不让看朋友圈显示什么 赘婿是什么意思
姜什么时候种植最好 吃羊肉不能吃什么东西 手足口病是什么病 吃阿胶对女人有什么好处 属猴配什么属相最好
背德感是什么意思hcv8jop8ns3r.cn 河豚有毒为什么还吃youbangsi.com 什么最重要tiangongnft.com 鲜为人知什么意思bfb118.com 血压低有什么办法hcv9jop2ns6r.cn
羊肉配什么菜好吃jinxinzhichuang.com canon是什么意思sanhestory.com 嘴角长疱疹是什么原因hcv7jop5ns3r.cn 娇喘是什么hcv9jop7ns4r.cn 眼睛斜视是什么原因hcv8jop5ns5r.cn
心率不齐是什么原因1949doufunao.com 什么是再生障碍性贫血hcv9jop3ns4r.cn 物以类聚是什么意思hcv9jop3ns4r.cn 日光性皮炎用什么药膏最有效hcv8jop9ns9r.cn 十一点是什么时辰hcv8jop2ns1r.cn
阴虚阳亢吃什么中成药hcv7jop6ns0r.cn 为什么会得盆腔炎hcv7jop5ns1r.cn 疏风解表的意思是什么hcv8jop4ns2r.cn 水瓶是什么星座hcv8jop0ns1r.cn 吃地瓜叶有什么好处和坏处hcv7jop4ns5r.cn
百度