Fix bug for ssh.set_config()

This commit is contained in:
Lance Edgar 2019-09-09 14:17:35 -05:00
parent 6e5131ad46
commit fec1c66422

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2019 Lance Edgar
#
# This file is part of Rattail.
#
@ -24,8 +24,6 @@
Fabric Library for SSH
"""
from __future__ import unicode_literals, absolute_import
def cache_host_key(c, host, for_user='root'):
"""
@ -67,7 +65,7 @@ def set_config(c, setting, value, path='/etc/ssh/sshd_config'):
c.sudo("""bash -c 'echo "{} {}" >> {}'""".format(setting, value, path))
else: # yep, uncomment existing definition, but also overwrite
c.sudo("sed -i .bak -e 's/^#{0} .*/{0} {1}/' {2}".format(setting, value, path))
c.sudo("sed -i.bak -e 's/^#{0} .*/{0} {1}/' {2}".format(setting, value, path))
else: # setting is defined, so overwrite it
c.sudo("sed -i.bak -e 's/^{0} .*/{0} {1}/' {2}".format(setting, value, path))