python中需要安装sftp吗
1个回答
展开全部
添加 paramiko 模块
#!/usr/bin/python
import paramiko
定义 ssh 连接函数
def ssh_connect( _host, _username, _password ):
try:
_ssh_fd = paramiko.SSHClient()
_ssh_fd.set_missing_host_key_policy( paramiko.AutoAddPolicy() )
_ssh_fd.connect( _host, username = _username, password = _password )
except Exception, e:
print( 'ssh %s@%s: %s' % (_username, _host, e) )
exit()
#!/usr/bin/python
import paramiko
定义 ssh 连接函数
def ssh_connect( _host, _username, _password ):
try:
_ssh_fd = paramiko.SSHClient()
_ssh_fd.set_missing_host_key_policy( paramiko.AutoAddPolicy() )
_ssh_fd.connect( _host, username = _username, password = _password )
except Exception, e:
print( 'ssh %s@%s: %s' % (_username, _host, e) )
exit()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询