I am installing certificates on a remote server and want to check whether they exist before I overwrite them. The server only allows non-root access via ssh public key. I can sudo -s
to root once in a shell. Root is required because /etc/ssl is not readable by anyone else. This is being developed in python fabric
, so any command that can be run in a shell command via sudo
would work. I don't mind typing in passwords at prompts in this case.
TL;DR: I need an sh
command that can tell my python program whether a remote file (or directory) exists when run as if fabric.sudo(sh_command) == True:
(or something similar).
Thank you!
from fabric.contrib.files import exists
def foo():
if exists('/path/to/remote/file', use_sudo=True):
#command
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With