sspark
2022-12-28 11ccc7d6264e8d89fdd9111521cf5a94d03288d6
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
 
export FWD_PORT=10000
export SSH_SERVER=root@onio.iptime.org
 
install_ssh_key()
{
    sudo ssh-keygen
    sudo ssh-copy-id -p 12222 $SSH_SERVER
}
 
test_tunnel()
{
    sudo /usr/bin/ssh -NT -o ServerAliveInterval=5 -o ExitOnForwardFailure=yes -gnN -R 127.0.0.1:$FWD_PORT:localhost:22 -p 12222 $SSH_SERVER
}
 
install_tunnel()
{
echo "
[Unit]
Description=SSH Tunnel with target server
After=network.target
 
[Service]
ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=5 -o ExitOnForwardFailure=yes -gnN -R 127.0.0.1:$FWD_PORT:localhost:22 -p 12222 $SSH_SERVER
RestartSec=10
Restart=always
 
[Install]
WantedBy=multi-user.target
" |  sudo tee /etc/systemd/system/tunnel.service  > /dev/null
 
    sudo systemctl daemon-reload
    sudo systemctl stop tunnel
    sudo systemctl start tunnel
    sudo systemctl enable tunnel
    sudo systemctl status tunnel
}
 
install_packages()
{
sudo apt-get update
sudo apt install -y vim git nodejs npm bluetooth bluez libbluetooth-dev libudev-dev bluez-hcidump
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
}
 
install_USBWiFi()
{
sudo apt install -y git dkms raspberrypi-kernel-headers build-essential bc
 
git clone https://github.com/aircrack-ng/rtl8812au.git
cd rtl8812au
sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile
sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/g' Makefile
 
sudo make dkms_install
}
 
case "$1" in
    copykey)
        echo -e "ssh_key copying... server: $SSH_SERVER"
        install_ssh_key
        ;;
    test)
        echo -e "tunnel test... port: $2"
        FWD_PORT=$2
        test_tunnel
        ;;        
    tunnel)
        echo -e "tunnel install... port: $2"
        FWD_PORT=$2
        install_tunnel
        ;;
    packages)
        echo -e "packages install..."
        install_packages
        ;;
    USBWiFi)
        echo -e "USBWiFi make install..."
        install_USBWiFi
        ;;
    *)
        echo -e "Usage:\n$0 {copykey|test 10000|tunnel 10000|packages|USBWiFi}"
        exit 1
esac