import time
import tempfile
+# TODO: Add retries to rcopy!! rcopy is not being retried!
logger = logging.getLogger("sshfuncs")
hostbyname_cache = dict()
def gethostbyname(host):
+ global hostbyname_cache
+
hostbyname = hostbyname_cache.get(host)
if not hostbyname:
hostbyname = socket.gethostbyname(host)
err_on_timeout = True,
connect_timeout = 30,
persistent = True,
- forward_x11 = False):
+ forward_x11 = False,
+ strict_host_checking = True):
"""
Executes a remote command, returns ((stdout,stderr),process)
"""
'-o', 'ControlPath=%s' % (make_control_path(agent, forward_x11),),
'-o', 'ControlPersist=60' ])
+ if not strict_host_checking:
+ # Do not check for Host key. Unsafe.
+ args.extend(['-o', 'StrictHostKeyChecking=no'])
+
if agent:
args.append('-A')
for x in xrange(retry):
# connects to the remote host and starts a remote connection
- proc = subprocess.Popen(args,
+ proc = subprocess.Popen(args,
+ env = env,
stdout = subprocess.PIPE,
stdin = subprocess.PIPE,
stderr = subprocess.PIPE)
agent = True,
recursive = False,
identity = None,
- server_key = None):
+ server_key = None,
+ strict_host_checking = True):
"""
Copies from/to remote sites.
tmp_known_hosts = make_server_key_args(server_key, host, port)
args.extend(['-o', 'UserKnownHostsFile=%s' % (tmp_known_hosts.name,)])
+ if not strict_host_checking:
+ # Do not check for Host key. Unsafe.
+ args.extend(['-o', 'StrictHostKeyChecking=no'])
+
if isinstance(source,list):
args.extend(source)
else: