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