Rajkishan Rajkishan - 2 years ago 56
Python Question

Python Move a File from Remote Machine to Local

I am new in python and trying different stuff.

Currently trying to copy a text file

from a remote machine with local ip
to my current machine.

What i tried from googling does not seem to work.

import paramiko
from scp import SCPClient

ssh = paramiko.SSHClient()
ssh.connect("[email protected]", password="look420")
scp = SCPClient(ssh.get_transport())

But, when i run this i get error;

Traceback (most recent call last):
File "/home/uc/Python_Projects/MoveFileAndFolder/move_remote.py", line 7, in <module>
ssh.connect("[email protected]", password="look420")
File "/usr/local/lib/python3.4/dist-packages/paramiko/client.py", line 296, in connect
to_try = list(self._families_and_addresses(hostname, port))
File "/usr/local/lib/python3.4/dist-packages/paramiko/client.py", line 200, in _families_and_addresses
addrinfos = socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM)
File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

What i am doing wrong here?

NOTE: Current machine is running
Debian Jessie
and the remote machine runs
Ubuntu 14.04.4 LTS

Answer Source

Did you try

ssh.connect("", username="testme", password="look420")

Please refer Doc

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download