blob: 736c2e654d4de7fdcc3d5edd91a6887839171f2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# 2fa-unix
2FA авторизация в unix система со своим сервером
### Build
```
gcc -fPIC -shared -o pam_2fact.so 2fact.c -lcurl -lpam
go build -o aserver server.go
```
### Install
```
sudo cp aserver /usr/local/bin/
sudo cp aserver.service /etc/systemd/system/
sudo cp pam_2fact.so /lib64/security/
systemctl daemon-reload
systemctl restart aserver.service
systemctl enable aserver
```
#### Register user
```
curl -X POST http://localhost:13031/api/v1/register \
-H "Content-Type: application/json" \
-d '{"username":"user","password":"pass"}'
```
### Get token
```
curl -X POST http://localhost:13031/api/v1/token \
-H "Content-Type: application/json" \
-d '{"username":"user","password":"pass"}'
```
#### Config PAM.d
```
echo "auth required pam_2fact.so username=<username> token=<token>" >> /etc/pam.d/system-auth
```
|