Use rsa keys for ssh in setup.py install
I am developing a python package that, when installed, should use SSH to communicate with remote servers. I have RSA key validation for all servers that I would like to connect to for my user, but I need to run setup.py with root privileges. Unfortunately, root cannot use the RSA keys I have, so I tried running commands from setup.py with downgraded permissions, but that didn't work. for example, to check if RSA: keys are working after running sudo python
on command line in python environment:
from subprocess import call
call(['ssh','-oBatchMode=yes',host])
gives Permission denied (publickey,password).
works only python
on command line and works with the same script works
execute sudo python
at the command line and then:
from subprocess import call
call(['sudo','-u','pi','ssh','-oBatchMode=yes',host])
gives the same error
works sudo python
, then:
call(['sudo','-u','pi','whoami'])
returns pi
as expected
Why can't I access RSA keys this way? What can I do to make this work?
source to share
No one has answered this question yet
Check out similar questions: