Dale Curtis | aa5eedb | 2011-08-23 16:18:52 -0700 | [diff] [blame] | 1 | # 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 Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 5 | def 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 Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 10 | - ConnectTimeout=30; maximum of 30 seconds allowed for an SSH connection |
| 11 | failure. Consistency with remote_access.sh. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 12 | |
Dale Curtis | aa5eedb | 2011-08-23 16:18:52 -0700 | [diff] [blame] | 13 | - 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 Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 17 | |
Chris Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 18 | - ServerAliveCountMax=3; consistency with remote_access.sh. |
| 19 | |
| 20 | - ConnectAttempts=4; reduce flakiness in connection errors; consistency |
| 21 | with remote_access.sh. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 22 | |
| 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 Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 25 | |
| 26 | - SSH protocol forced to 2; needed for ServerAliveInterval. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 27 | """ |
| 28 | base_command = ('/usr/bin/ssh -a -x %s -o StrictHostKeyChecking=no' |
| 29 | ' -o UserKnownHostsFile=/dev/null -o BatchMode=yes' |
Chris Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 30 | ' -o ConnectTimeout=30 -o ServerAliveInterval=180' |
| 31 | ' -o ServerAliveCountMax=3 -o ConnectionAttempts=4' |
| 32 | ' -o Protocol=2 -l %s -p %d') |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 33 | return base_command % (opts, user, port) |