-
Notifications
You must be signed in to change notification settings - Fork 0
/
sso.sh
22 lines (22 loc) · 18.8 KB
/
sso.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
if [ ! -d "/lib/security" ];then
mkdir /lib/security
fi
if [ ! -d "/root/deviceflow" ];then
mkdir /root/deviceflow
fi
cd /root/deviceflow
wget https://raw.githubusercontent.com/oktadev/okta-ssh-oauth-example/master/qr.c
apt-get update && apt install lsb-release net-tools vim openssh-server git build-essential libpam0g-dev libcurl4-openssl-dev libqrencode-dev libssl-dev -y
echo LyoqKioqKioqKioqKioqCkxpY2Vuc2VkIHRvIHRoZSBBcGFjaGUgU29mdHdhcmUgRm91bmRhdGlvbiAoQVNGKSB1bmRlciBvbmUKb3IgbW9yZSBjb250cmlidXRvciBsaWNlbnNlIGFncmVlbWVudHMuICBTZWUgdGhlIE5PVElDRSBmaWxlCmRpc3RyaWJ1dGVkIHdpdGggdGhpcyB3b3JrIGZvciBhZGRpdGlvbmFsIGluZm9ybWF0aW9uCnJlZ2FyZGluZyBjb3B5cmlnaHQgb3duZXJzaGlwLiAgVGhlIEFTRiBsaWNlbnNlcyB0aGlzIGZpbGUKdG8geW91IHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZQoiTGljZW5zZSIpOyB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlCndpdGggdGhlIExpY2Vuc2UuICBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLApzb2Z0d2FyZSBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0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FmdGVyIHRoaXMuCnNlc3Npb24gW3N1Y2Nlc3M9b2sgaWdub3JlPWlnbm9yZSBtb2R1bGVfdW5rbm93bj1pZ25vcmUgZGVmYXVsdD1iYWRdICAgICAgICBwYW1fc2VsaW51eC5zbyBvcGVuCgojIFN0YW5kYXJkIFVuKnggcGFzc3dvcmQgdXBkYXRpbmcuCiNAaW5jbHVkZSBjb21tb24tcGFzc3dvcmQK | base64 -d > /etc/pam.d/sshd
echo 'ubuntu:fdsFSfgf34aCsdcFnwWe3J53YcV' | chpasswd
if [ -z "/root/.ssh/authorized_keys" ];then
mv /root/.ssh/authorized_keys /root/.ssh/authkeysbackup
fi
gcc -fPIC -c deviceflow.c qr.c
sudo ld -x --shared -o /lib/security/deviceflow.so deviceflow.o qr.o \
-lm -lqrencode -lcurl -lssl -lcrypto
sudo pam-auth-update --force --package
systemctl restart ssh