这有效:
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
with pysftp.Connection('ftpsite.com', username='xxx', password='xxx', cnopts=cnopts) as sftp:
with sftp.cd('inbox'):
sftp.get('WinSCP.ini')
但是现在我想测试ftp(端口21),所以我添加了port属性:
with pysftp.Connection('ftpsite.com', port=21 , username='xxx', password='xxx', cnopts=cnopts) as sftp:
现在我明白了:
异常:paramiko.ssh_exception.SSHException 消息:读取SSH协议标语
时出错我很困惑...
答案 0 :(得分:0)
SFTP使用SSH,因此其PORT 22而不是21
FTP使用端口21
就像错误所说,ssh异常。尝试使用“ port = 22”
来源:
<div class="body-content">
<div class="container">
<div class="content-left">
<div class="slider">
<div class="slider-control">
<span id="prev"><</span>
<span id="next">></span>
</div>
<div class="cycle-slideshow" data-cycle-fx="fade" data-cycle-slides="> div" data-cycle-timeout="2000">
<img src="images/slide1.jpg">
<div class="cycle-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris id pulvinar libero, quis aliquet nisi. Fusce ullamcorper, nisi ut porttitor cursus, lectus sem aliquet nulla, eget interdum nisl metus id ante.</div>
</div>
<div>
<img src="images/slide2.jpeg">
<div class="cycle-overlay">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris id pulvinar libero, quis aliquet nisi. Fusce ullamcorper, nisi ut porttitor cursus, lectus sem aliquet nulla, eget interdum nisl metus id ante.</div>
</div>
</div>
</div>
</div>
<div class="content-right">
</div>
</div>
</div>
<script src="js/jquery.cycle.all.js"></script>
<script src=js/jquery-3.3.1.min.js></script>
<script>
$("#next").click(function() {
$(".cycle-slideshow").cycle('next');
});
$("#prev").click(function() {
$(".cycle-slideshow").cycle('prev');
});
</script>
</body>
</html>
答案 1 :(得分:0)
pysftp库仅使用SFTP协议进行通话,该协议不同于“常规” FTP协议。因此,您所看到的是程序尝试通过SFTP与FTP服务器进行通信,并且不理解它返回的响应时出现的错误。