简体   繁体   中英

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")

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.

When we run same python program in background using nohup then same prompt sometimes appears sometimes it dose not appears.

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 .

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. If there is a mismatch in these details it asks you to confirm whether the machine u SSHed is the correct machine or not. So making these changes, all went well. references: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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