Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main_deploy(host, user, secret, pport, proxy_pass): # функция разворачивает Socks5 proxy на сервер, используя
- # стандартный порт 1080, подключаться пожно под пользователем root или proxy
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(hostname=host, username=user, password=secret, port=22)
- ssh = client.invoke_shell()
- time.sleep(2)
- out = ssh.recv(60000)
- # print(out)
- name = str(out[-16:])
- print("Server user:" + name)
- print("Work starting")
- ssh.send("sudo apt update && sudo apt install dante-server" + "\n")
- time.sleep(1)
- while True:
- out = ssh.recv(60000)
- # print(out)
- if str(out[-16:]) == name:
- print("Update and dante install complete")
- break
- else:
- print("Wait fo it!")
- time.sleep(5)
- ssh.send("echo logoutput: stderr > /etc/danted.conf" + "\n")
- ssh.send("ifacer=`ip r | grep default | grep -Po '(?<=dev )(\S+)'`" + "\n")
- ssh.send("echo internal: ${ifacer} port = " + pport + " >> /etc/danted.conf" + "\n")
- ssh.send("echo external: ${ifacer} >> /etc/danted.conf" + "\n")
- ssh.send("echo method: username >> /etc/danted.conf" + "\n")
- ssh.send("echo user.privileged: root >> /etc/danted.conf" + "\n")
- ssh.send("echo user.notprivileged: nobody >> /etc/danted.conf" + "\n")
- ssh.send("echo user.libwrap: nobody >> /etc/danted.conf" + "\n")
- ssh.send("echo client pass { >> /etc/danted.conf" + "\n")
- ssh.send('echo -e "\\tfrom: 0.0.0.0/0 to: 0.0.0.0/0" >> /etc/danted.conf' + "\n")
- ssh.send('echo -e "\\tlog: error connect disconnect">> /etc/danted.conf' + "\n")
- ssh.send("echo } >> /etc/danted.conf" + "\n")
- ssh.send("echo client block { >> /etc/danted.conf" + "\n")
- ssh.send('echo -e "\\tfrom: 0.0.0.0/0 to: 0.0.0.0/0" >> /etc/danted.conf' + "\n")
- ssh.send('echo -e "\\tlog: connect error" >> /etc/danted.conf' + "\n")
- ssh.send("echo } >> /etc/danted.conf" + "\n")
- ssh.send("echo pass { >> /etc/danted.conf" + "\n")
- ssh.send('echo -e "\\tfrom: 0.0.0.0/0 to: 0.0.0.0/0" >> /etc/danted.conf' + "\n")
- ssh.send('echo -e "\\tlog: error connect disconnect" >> /etc/danted.conf' + "\n")
- ssh.send("echo } >> /etc/danted.conf" + "\n")
- ssh.send("echo block { >> /etc/danted.conf" + "\n")
- ssh.send('echo -e "\\tfrom: 0.0.0.0/0 to: 0.0.0.0/0" >> /etc/danted.conf' + "\n")
- ssh.send('echo -e "\\tlog: connect error" >> /etc/danted.conf' + "\n")
- ssh.send("echo } >> /etc/danted.conf" + "\n")
- print("Config file created")
- ssh.send("service danted restart" + "\n")
- time.sleep(5)
- print("Dante restarted")
- ssh.send('passwd proxy' + "\n")
- print("Password changing")
- ssh.send(proxy_pass + "\n")
- time.sleep(1)
- print("Password changed")
- ssh.send(proxy_pass + "\n")
- print("Done")
Add Comment
Please, Sign In to add comment