2 # Copyright (c) 2015 All rights reserved
3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
11 home = os.getenv("HOME")
12 SSH_CONFIG = {'TMP_SSH_CONFIG': "./tmp/ssh_config",
13 'ID_RSA_PATH': "%s/.ssh/id_rsa" % home}
16 class SshUtil(object):
19 def gen_ssh_config(node_list):
20 config = ["UserKnownHostsFile=/dev/null",
21 "StrictHostKeyChecking=no",
23 "GSSAPIAuthentication=no",
25 for node in node_list:
26 config.append(node.to_ssh_config())
27 with open(SSH_CONFIG['TMP_SSH_CONFIG'], 'w') as f:
28 f.write('\n'.join(config))
31 def get_config_file_path():
32 return SSH_CONFIG['TMP_SSH_CONFIG']
36 return SSH_CONFIG['ID_RSA_PATH']