fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] ssh -i && env.key_filename


From: santosh kumar
Subject: Re: [Fab-user] ssh -i && env.key_filename
Date: Sat, 22 Oct 2016 22:59:06 +0530

if i am trying to connect over a normal ssh connect it working good.

how to use the "-i" option in fabric, do we need anyother options ?
for me fabric is working good with a username/password , code is good. Just that i am not able to use the sshkey in the fabric file.

Thanks,
santosh D

On Sat, Oct 22, 2016 at 10:51 PM, R M Waters <address@hidden> wrote:
I would work backwards by first figuring out what the sysadmin did to restrict login on the server, that info will help you figure out why ssh client works but fabric/paramiko doesn't.  Or maybe you are doing something funny in `exec_remote_cmd`.

On Sat, Oct 22, 2016 at 12:56 PM, santosh kumar <address@hidden> wrote:
All,

I have done all the set up for the private and public keys. Later when i am using the ssh keys it working as expected.

 ssh -i latest_my_node_rsa address@hidden 'sudo /usr/bin/virsh list --all'
   _________________________________________________________________
 Id    Name                           State
----------------------------------------------------
 2     chcilvLmong01                  running
 3     chcilvlvipr02                  running
 4     chcilvLswft01                  running
 5     chcilvLcomp03                  running
 6     chcilvLdbng01                  running
 7     chcilvLmosc03                  running
 8     chcilvLrosv01                  running

But the challenge is using it with fabric i am getting following errors when trying with following setting from fabric


[chcilrsv130] Executing task 'kvm_gamma_car'
[chcilrsv130] run: sudo /usr/bin/virsh list --all
[chcilrsv130] out:                        ***************************************************
[chcilrsv130] out:                        ********************************************************
[chcilrsv130] out:                        ** Direct network login to this account is disallowed **
[chcilrsv130] out:                        ********************************************************
[chcilrsv130] out:                        ***************************************************
[chcilrsv130] out:
[chcilrsv130] out:


Warning: run() received nonzero return code 1 while executing 'sudo /usr/bin/virsh list --all'!

Following is the config file

def kvm_gamma_car():
  ''' : This is a functionality to generate the list for kvm guests,kvm hosts,kvm ips '''
  env.user = ADMIN
  env.key_filename=KEY_PASS
  cmdlist = {'virsh':'sudo /usr/bin/virsh list --all'}
  try:
    for key,cmd in cmdlist.items():
      results = exec_remote_cmd(cmd)
    Nresults=re.findall('[0-9]+\s+(\S+)\s+\S+',results)
    domain = re.search('\w+(\S+)',env.host).group(1)
    print "\n Nresults: {} \n".format(Nresults)
    if Nresults:
      for value in Nresults:
        gname = value+domain
        kname = env.host
        print "working on {} \n".format(gname,kname)
        if session.query(MyNode).filter_by(Guest_Name=gname).count() < 1:
          print "Adding the following entries - {},{} \n".format(gname,kname)
          Db_Entry(gname,kname)
        elif session.query(MyNode).filter_by(Guest_Name=gname).filter_by(Kvm_Name=kname).count() == 1 :
          print "Already have an entry for the same - {},{}".format(gname,kname)
        else:
          print "updating a new entry - {},{}".format(gname,kname)
          session.query(MyNode).filter_by(Guest_Name=gname).update({"Kvm_Name":kname})
          session.commit()
    else:
       print "Adding the following entries - {},{} \n".format(kname,kname)
       Db_Entry(gname,kname)
  except:
      kvm_down.write("{0},{1}\n".format("KVM NODE DOWN",env.host))


----
ADMIN= 'm04949'
KEY_PASS = 'latest_my_node_rsa'

Could you let me know where i am missing ? In btw its fabric Fabric==1.10.2


Thanks,
Santosh D




_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user




reply via email to

[Prev in Thread] Current Thread [Next in Thread]