2013-07-01 23:41:22 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
|
|
|
import os.path
|
|
|
|
|
|
|
|
|
|
|
|
class EnableShadowConfig(Task):
|
|
|
|
description = 'Enabling shadowconfig'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-01 23:41:22 +02:00
|
|
|
from common.tools import log_check_call
|
2014-02-23 22:16:10 +01:00
|
|
|
log_check_call(['chroot', info.root, 'shadowconfig', 'on'])
|
2013-07-01 23:41:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
class DisableSSHPasswordAuthentication(Task):
|
|
|
|
description = 'Disabling SSH password authentication'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-01 23:41:22 +02:00
|
|
|
from common.tools import sed_i
|
|
|
|
sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
|
|
|
sed_i(sshd_config_path, '^#PasswordAuthentication yes', 'PasswordAuthentication no')
|
|
|
|
|
|
|
|
|
|
|
|
class DisableSSHDNSLookup(Task):
|
|
|
|
description = 'Disabling sshd remote host name lookup'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-01 23:41:22 +02:00
|
|
|
sshd_config_path = os.path.join(info.root, 'etc/ssh/sshd_config')
|
|
|
|
with open(sshd_config_path, 'a') as sshd_config:
|
|
|
|
sshd_config.write('UseDNS no')
|