blob: 361d1adf171de625c5c62797f89c317818f4b3d1 [file] [log] [blame]
Dale Curtisaa5eedb2011-08-23 16:18:52 -07001# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Dale Curtiscb7bfaf2011-06-07 16:21:57 -07005def make_ssh_command(user='root', port=22, opts='', hosts_file=None,
6 connect_timeout=None, alive_interval=None):
7 """Override default make_ssh_command to use options tuned for Chrome OS.
8
9 Tuning changes:
Chris Sosaf7fcd6e2011-09-27 17:30:47 -070010 - ConnectTimeout=30; maximum of 30 seconds allowed for an SSH connection
11 failure. Consistency with remote_access.sh.
Dale Curtiscb7bfaf2011-06-07 16:21:57 -070012
Dale Curtisaa5eedb2011-08-23 16:18:52 -070013 - ServerAliveInterval=180; which causes SSH to ping connection every
14 180 seconds. In conjunction with ServerAliveCountMax ensures that if the
15 connection dies, Autotest will bail out quickly. Originally tried 60 secs,
16 but saw frequent job ABORTS where the test completed successfully.
Dale Curtiscb7bfaf2011-06-07 16:21:57 -070017
Chris Sosaf7fcd6e2011-09-27 17:30:47 -070018 - ServerAliveCountMax=3; consistency with remote_access.sh.
19
20 - ConnectAttempts=4; reduce flakiness in connection errors; consistency
21 with remote_access.sh.
Dale Curtiscb7bfaf2011-06-07 16:21:57 -070022
23 - UserKnownHostsFile=/dev/null; we don't care about the keys. Host keys
24 change with every new installation, don't waste memory/space saving them.
Chris Sosaf7fcd6e2011-09-27 17:30:47 -070025
26 - SSH protocol forced to 2; needed for ServerAliveInterval.
Dale Curtiscb7bfaf2011-06-07 16:21:57 -070027 """
28 base_command = ('/usr/bin/ssh -a -x %s -o StrictHostKeyChecking=no'
29 ' -o UserKnownHostsFile=/dev/null -o BatchMode=yes'
Chris Sosaf7fcd6e2011-09-27 17:30:47 -070030 ' -o ConnectTimeout=30 -o ServerAliveInterval=180'
31 ' -o ServerAliveCountMax=3 -o ConnectionAttempts=4'
32 ' -o Protocol=2 -l %s -p %d')
Dale Curtiscb7bfaf2011-06-07 16:21:57 -070033 return base_command % (opts, user, port)