Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Paramiko change IP of remote machine
- try:
- guest.connect("10.22.254.200", username='root',password='root')
- except SSHException as detail:
- session.flash = detail.message
- else:
- sftp = guest.open_sftp()
- sftp.put('./scripts/change-ip', '/root/change-ip')
- sftp.close()
- guest.exec_command('chmod +x /root/change-ip')
- time.sleep(5)
- try:
- stdin,stdout,stderr = guest.exec_command('/root/change-ip 10.22.254.200 &')
- set -x
- cp /etc/conf.d/net /etc/conf.d/net.bak
- sed "s/10.22.254.200/$1/g" /etc/conf.d/net.bak > /etc/conf.d/net
- /etc/init.d/net.eth0 restart
Add Comment
Please, Sign In to add comment