简体   繁体   English

在python中使用Fabric连接到主机时,出现提示(“ root”的登录密码:)要求输入root密码

[英]while connecting to a host using fabric in python, getting a prompt(Login password for 'root':) asking for root password

In python file code is something like this: with settings(host_string=elasticIP, key_filename = '/path/to/keyfile.pem', user = 'root', use_ssh_config = False): run("any command") 在python文件中,代码是这样的:设置(host_string = elasticIP,key_filename ='/path/to/keyfile.pem',user='root',use_ssh_config = False):run(“ any command”)

After executing this, a prompt appears in console stating "Login password for 'root':" As we dont have a password for this user 'root' so we are not sure what password to provide, but, randomly giving any text as a password for 'root' in the console it accepts and moves further. 执行完此操作后,控制台中将出现提示,提示“ root用户的登录密码:”由于我们没有该root用户的密码,因此我们不确定要提供什么密码,而是随机输入任何文本作为密码对于控制台中的“ root”,它接受并进一步移动。

When we run same python program in background using nohup then same prompt sometimes appears sometimes it dose not appears. 当我们使用nohup在后台运行相同的python程序时,有时会出现相同的提示,有时却不会出现。

We are working on eucalyptus instances and hope environment is not an issue here. 我们正在研究桉树实例,希望这里的环境不是问题。 Please suggest... 请建议...

When you are using settings , don't use run , use execute . 使用settings ,请勿使用run ,而应使用execute

from fabric.decorators import task
from fabric.operations import run, execute

def my_command():
    run('echo "hello fabric!"')

@task
def my_task():
    with settings(host_string=elasticIP, key_filename = '/path/to/keyfile.pem', user = 'root', use_ssh_config = False):
        execute(my_command)

I diged more into this issue and finally got an answer: file :/etc/ssh/ssh_config holds a property 'UserKnownHostsFile' and 'StrictHostKeyChecking' these properties should be addressed as : StrictHostKeyChecking no UserKnownHostsFile=/dev/null UserKnownHostsFile defines the storing of ssh and some metadata regarding to a particular machine. 我深入研究了这个问题,并最终得到了一个答案:file:/ etc / ssh / ssh_config拥有一个属性'UserKnownHostsFile'和'StrictHostKeyChecking',这些属性的地址应为:StrictHostKeyChecking no UserKnownHostsFile = / dev / null UserKnownHostsFile定义了以下内容的存储ssh和有关特定计算机的一些元数据。 If there is a mismatch in these details it asks you to confirm whether the machine u SSHed is the correct machine or not. 如果这些详细信息不匹配,它将要求您确认SSH SSH的计算机是否为正确的计算机。 So making these changes, all went well. 因此,进行这些更改,一切都进行顺利。 references: http://linuxcommando.blogspot.in/2008/10/how-to-disable-ssh-host-key-checking.html 参考: http : //linuxcommando.blogspot.in/2008/10/how-to-disable-ssh-host-key-checking.html

and

https://superuser.com/questions/19563/how-do-i-skip-the-known-host-question-the-first-time-i-connect-to-a-machine-vi https://superuser.com/questions/19563/how-do-i-skip-the-known-host-question-the-first-time-i-connect-to-a-machine-vi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM