Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- ## ADDING SWAP
- server = '127.0.0.1'
- user = 'root'
- pwd = 'pass'
- msg = "Agregando swap a... " + server
- print(msg)
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(server, username = user, password = pwd)
- com = ""
- com = com + "fallocate -l 2G /swapfile \n"
- com = com + "chmod 600 /swapfile \n"
- com = com + "mkswap /swapfile \n"
- com = com + "swapon /swapfile \n"
- com = com + "echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab \n"
- com = com + "reboot\n"
- stdin, stdout, stderr = ssh.exec_command(com)
- stdout.channel.recv_exit_status()
- for line in stdout.readlines():
- print(line)
- ssh.close()
- ####################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement