Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import paramiko
- import getpass
- def ssh_command(ssh):
- command = 'cd plataforma ; source venv/bin/activate; python manage.py runserver 0:8000;'
- ssh.invoke_shell()
- stdin, stdout, stderr = ssh.exec_command(command)
- print(stdout.read())
- def ssh_connect(host, user, key):
- try:
- ssh = paramiko.SSHClient()
- print('Calling paramiko')
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(hostname=host, username=user, password=key)
- ssh_command(ssh)
- except Exception as e:
- print('Connection Failed')
- print(e)
- if __name__=='__main__':
- user = 'root'
- key = '123123'
- host = 'xxx.xxx.xxx.xxx'
- ssh_connect(host, user, key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement