Reputation: 2698
I was trying to make a connection to a Free Public SFTP Server that I found here using pysftp.
I tried:
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
sftp = pysftp.Connection('demo.wftpserver.com:2222', username='demo-user', password='demo-user', cnopts=cnopts)
sftp.close()
However it yields:
ConnectionException: ('demo.wftpserver.com:2222', 22)
and gaierror: [Errno -2] Name or service not known
Is this a workaround to this issue?
Please Advise.
Upvotes: 0
Views: 762
Reputation: 202242
The port number goes to the port
parameter of Connection
constructor. The host
parameter takes just a hostname.
sftp = pysftp.Connection(
'demo.wftpserver.com', port=2222, username='demo-user', password='demo-user',
cnopts=cnopts)
Obligatory warning: Do not set cnopts.hostkeys = None
, unless you do not care about security. For the correct solution see Verify host key with pysftp.
Upvotes: 1