我正在尝试通过SFTP与paramiko和Python 2.7连接,以最终从远程服务器获取文件并将其放入我的服务器。 (请注意,它也使用非标准端口)
但是,当我尝试连接时-需要花费很长时间,然后出现身份验证错误。您是否有此问题有修复建议?
我没有密钥,它只使用用户名/密码。我可以连接图形SSH程序而不会出现问题,因此凭据似乎正确。
这是代码:
hostname = 'remotehostname.com'
username= 'AB1239'
password= ‘password’
port = 10022
import paramiko
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(hostname=hostname, username=username, password=password,port=port)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 380, in connect
look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 597, in _auth
raise saved_exception
paramiko.ssh_exception.AuthenticationException: Authentication failed.
I am using:
>>> print paramiko.__version__
1.16.1
和python Python 2.7.5(在Linux上)
http://docs.paramiko.org/en/2.4/api/transport.html#(这些是针对版本2.4的,但请注意,我使用的是较早的版本) http://docs.paramiko.org/en/2.4/api/client.html 我也看了这个:Why does Paramiko hang if you use it while loading a module? 但仍然存在连接问题。
答案 0 :(得分:-2)
我不太确定是否能100%地回答您的问题,但我认为总比没有回答要好,尤其是因为我确定它可以解决您的问题,即使我没有对此进行测试释放(没有默认端口)。
# declare function to specify parameters for GBM model
gbm_rxBTrees <- function(data, formula, nTree, learningRate){
model <- rxBTrees(
formula=formula,
data=train,
importance = T, lossFunction = "bernoulli",
nTree = nTree, # Number of Trees
learningRate = learningRate, # Learning Rate or Shrinkage
maxDepth = 7, # Max depth of a single tree
#minBucket = 2 # min observation in a node for splitting
mTry = 0.8, # Percentage of variables to take to build each tree
sampRate = 0.8, # value specifying the percentage(s) of observations to sample for each tree
replace = T
)
return(model)}
# formula of predicted ~ predictors
form <- formula(DepDelay_flag ~ Origin + Dest + Distance + Month + DayOfWeek + UniqueCarrier + Dep_hour)
# set argument list for parallel execution in rxExec()
argList2 <- list(list(nTree = 300, learningRate = 0.1), list(nTree = 600, learningRate = 0.05))
# growing trees : building model
system.time(resrxBTrees <- rxExec(gbm_rxBTrees, data = train, formula = form, elemArgs = argList2))