Guest User

Untitled

a guest
Sep 13th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Paramiko change IP of remote machine
  2. try:
  3. guest.connect("10.22.254.200", username='root',password='root')
  4. except SSHException as detail:
  5. session.flash = detail.message
  6. else:
  7. sftp = guest.open_sftp()
  8. sftp.put('./scripts/change-ip', '/root/change-ip')
  9. sftp.close()
  10. guest.exec_command('chmod +x /root/change-ip')
  11. time.sleep(5)
  12. try:
  13. stdin,stdout,stderr = guest.exec_command('/root/change-ip 10.22.254.200 &')
  14.  
  15. set -x
  16. cp /etc/conf.d/net /etc/conf.d/net.bak
  17. sed "s/10.22.254.200/$1/g" /etc/conf.d/net.bak > /etc/conf.d/net
  18. /etc/init.d/net.eth0 restart
Add Comment
Please, Sign In to add comment