반응형
from paramiko import SSHClient
from scp import SCPClient
import paramiko
# id info
ipaddress ='192.168.17.131'
name = 'root'
pw = 'horae'
ssh = SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ipaddress,username=name,password=pw)
ssh.exec_command('mkdir sg_test')
# SCPCLient takes a paramiko transport as its only argument
scp = SCPClient(ssh.get_transport())
scp.put('d:\\000\linux.sh','sg_test')
ssh.exec_command('chmod 755 sg_test/linux.sh')
stdin,stdout,stderr = ssh.exec_command('cd ./sg_test; ./linux.sh')
print stdout.readlines()
ssh.exec_command('cd ./sg_test; mv *.txt '+ipaddress+'.txt')
scp.get('sg_test/'+ipaddress+'.txt','d:\\000')
ssh.exec_command('rm -rf ./sg_test')
scp.close()
반응형
'IT기술 관련 > 파이썬_루비 등 언어' 카테고리의 다른 글
[파이썬] typeError: isinstance() arg 2 must be a type or tuple of types 에러 해결 (0) | 2016.09.21 |
---|---|
[파이썬] 특정 파일 서버 가동후 가져오기 (0) | 2016.09.20 |
파이썬 SCP 오픈 소스 (0) | 2016.09.20 |
paramiko ssh 및 scp 데모 (0) | 2016.09.12 |
파이썬3 ssh모듈 paramiko 설치 및 설정 (0) | 2016.09.12 |