Discussion:
[Fab-user] ssh -i && env.key_filename
santosh kumar
2016-10-22 16:56:10 UTC
Permalink
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 ***@chcilrsv130 '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
R M Waters
2016-10-22 17:21:18 UTC
Permalink
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`.
Post by santosh kumar
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.
--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: ******************************
*********************
Warning: run() received nonzero return code 1 while executing 'sudo
/usr/bin/virsh list --all'!
Following is the config file
''' : 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'}
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)
gname = value+domain
kname = env.host
print "working on {} \n".format(gname,kname)
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()
print "Already have an entry for the same -
{},{}".format(gname,kname)
print "updating a new entry - {},{}".format(gname,kname)
session.query(MyNode).filter_by(Guest_Name=gname).update({"
Kvm_Name":kname})
session.commit()
print "Adding the following entries - {},{} \n".format(kname,kname)
Db_Entry(gname,kname)
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
https://lists.nongnu.org/mailman/listinfo/fab-user
santosh kumar
2016-10-22 17:29:06 UTC
Permalink
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
Post by R M Waters
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`.
Post by santosh kumar
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.
--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: ******************************
*********************
Warning: run() received nonzero return code 1 while executing 'sudo
/usr/bin/virsh list --all'!
Following is the config file
''' : 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'}
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)
gname = value+domain
kname = env.host
print "working on {} \n".format(gname,kname)
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()
print "Already have an entry for the same -
{},{}".format(gname,kname)
print "updating a new entry - {},{}".format(gname,kname)
session.query(MyNode).filter_by(Guest_Name=gname).update({"K
vm_Name":kname})
session.commit()
print "Adding the following entries - {},{} \n".format(kname,kname)
Db_Entry(gname,kname)
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
https://lists.nongnu.org/mailman/listinfo/fab-user
Brandon Whaley
2016-10-22 22:28:02 UTC
Permalink
It sounds like that user is not allowed to run shells. Try setting
env.shell to an empty string. You'll lose the ability to use any shell
specific commands via run but what you're running in your example should be
fine.
Post by santosh kumar
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
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`.
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.
--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: ** Direct network login to this
account is disallowed **
********************************************************
***************************************************
Warning: run() received nonzero return code 1 while executing 'sudo
/usr/bin/virsh list --all'!
Following is the config file
''' : 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'}
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)
gname = value+domain
kname = env.host
print "working on {} \n".format(gname,kname)
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()
print "Already have an entry for the same -
{},{}".format(gname,kname)
print "updating a new entry - {},{}".format(gname,kname)
session.query(MyNode).filter_by(Guest_Name=gname).update({"Kvm_Name":kname})
session.commit()
print "Adding the following entries - {},{} \n".format(kname,kname)
Db_Entry(gname,kname)
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
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Jeff Forcier
2016-10-22 23:54:31 UTC
Permalink
You might also want to try setting env.use_shell = False.
Post by Brandon Whaley
It sounds like that user is not allowed to run shells. Try setting
env.shell to an empty string. You'll lose the ability to use any shell
specific commands via run but what you're running in your example should be
fine.
Post by santosh kumar
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
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`.
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.
--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: ******************************
*********************
Warning: run() received nonzero return code 1 while executing 'sudo
/usr/bin/virsh list --all'!
Following is the config file
''' : 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'}
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)
gname = value+domain
kname = env.host
print "working on {} \n".format(gname,kname)
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()
print "Already have an entry for the same -
{},{}".format(gname,kname)
print "updating a new entry - {},{}".format(gname,kname)
session.query(MyNode).filter_by(Guest_Name=gname).update({"
Kvm_Name":kname})
session.commit()
print "Adding the following entries - {},{} \n".format(kname,kname)
Db_Entry(gname,kname)
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
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
santosh kumar
2016-10-24 06:28:52 UTC
Permalink
Thank you all.

Jeff,

you solution of using env.use_shell = False worked great.

Thanks,
santosh D
Post by Jeff Forcier
You might also want to try setting env.use_shell = False.
Post by Brandon Whaley
It sounds like that user is not allowed to run shells. Try setting
env.shell to an empty string. You'll lose the ability to use any shell
specific commands via run but what you're running in your example should be
fine.
Post by santosh kumar
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
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`.
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.
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: ******************************
*********************
Warning: run() received nonzero return code 1 while executing 'sudo
/usr/bin/virsh list --all'!
Following is the config file
''' : 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'}
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)
gname = value+domain
kname = env.host
print "working on {} \n".format(gname,kname)
print "Adding the following entries - {},{}
\n".format(gname,kname)
Db_Entry(gname,kname)
elif session.query(MyNode).filter_b
print "Already have an entry for the same -
{},{}".format(gname,kname)
print "updating a new entry - {},{}".format(gname,kname)
session.query(MyNode).filter_by(Guest_Name=gname).update({"K
vm_Name":kname})
session.commit()
print "Adding the following entries - {},{}
\n".format(kname,kname)
Db_Entry(gname,kname)
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
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
Loading...