Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: remote_access.sh

Issue 6311002: Revert "remote_access.sh: remove dependence on ssh-agent" (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Library for setting up remote access and running remote commands. 5 # Library for setting up remote access and running remote commands.
6 6
7 DEFAULT_PRIVATE_KEY="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/\ 7 DEFAULT_PRIVATE_KEY="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/\
8 ssh_keys/testing_rsa" 8 ssh_keys/testing_rsa"
9 9
10 DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance" 10 DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance"
11 DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \ 11 DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \
12 "Private key of root account on remote host" 12 "Private key of root account on remote host"
13 DEFINE_integer ssh_port 22 \ 13 DEFINE_integer ssh_port 22 \
14 "SSH port of the remote machine running Chromium OS instance" 14 "SSH port of the remote machine running Chromium OS instance"
15 15
16 # Copies $1 to $2 on remote host 16 # Copies $1 to $2 on remote host
17 function remote_cp_to() { 17 function remote_cp_to() {
18 REMOTE_OUT=$(scp -P ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \ 18 REMOTE_OUT=$(scp -P ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
19 -o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY $1 \ 19 UserKnownHostsFile=$TMP_KNOWN_HOSTS $1 root@$FLAGS_remote:$2)
20 root@$FLAGS_remote:$2)
21 return ${PIPESTATUS[0]} 20 return ${PIPESTATUS[0]}
22 } 21 }
23 22
24 # Copies a list of remote files specified in file $1 to local location 23 # Copies a list of remote files specified in file $1 to local location
25 # $2. Directory paths in $1 are collapsed into $2. 24 # $2. Directory paths in $1 are collapsed into $2.
26 function remote_rsync_from() { 25 function remote_rsync_from() {
27 rsync -e "ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \ 26 rsync -e "ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
28 -o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY" \ 27 UserKnownHostsFile=$TMP_KNOWN_HOSTS" --no-R \
29 --no-R --files-from=$1 root@${FLAGS_remote}:/ $2 28 --files-from=$1 root@${FLAGS_remote}:/ $2
30 } 29 }
31 30
32 function remote_sh() { 31 function remote_sh() {
33 REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \ 32 REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
34 -o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY \ 33 UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@")
35 root@$FLAGS_remote "$@")
36 return ${PIPESTATUS[0]} 34 return ${PIPESTATUS[0]}
37 } 35 }
38 36
39 function remote_sh_allow_changed_host_key() { 37 function remote_sh_allow_changed_host_key() {
40 rm -f $TMP_KNOWN_HOSTS 38 rm -f $TMP_KNOWN_HOSTS
41 remote_sh "$@" 39 remote_sh "$@"
42 } 40 }
43 41
44 function set_up_remote_access() { 42 function set_up_remote_access() {
43 if [ -z "$SSH_AGENT_PID" ]; then
44 eval $(ssh-agent)
45 OWN_SSH_AGENT=1
46 else
47 OWN_SSH_AGENT=0
48 fi
45 cp $FLAGS_private_key $TMP_PRIVATE_KEY 49 cp $FLAGS_private_key $TMP_PRIVATE_KEY
46 chmod 0400 $TMP_PRIVATE_KEY 50 chmod 0400 $TMP_PRIVATE_KEY
51 ssh-add $TMP_PRIVATE_KEY
47 52
48 # Verify the client is reachable before continuing 53 # Verify the client is reachable before continuing
49 echo "Initiating first contact with remote host" 54 echo "Initiating first contact with remote host"
50 remote_sh "true" 55 remote_sh "true"
51 echo "Connection OK" 56 echo "Connection OK"
52 } 57 }
53 58
54 # Ask the target what board it is 59 # Ask the target what board it is
55 function learn_board() { 60 function learn_board() {
56 [ -n "${FLAGS_board}" ] && return 61 [ -n "${FLAGS_board}" ] && return
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 134
130 function remote_access_init() { 135 function remote_access_init() {
131 TMP_PRIVATE_KEY=$TMP/private_key 136 TMP_PRIVATE_KEY=$TMP/private_key
132 TMP_KNOWN_HOSTS=$TMP/known_hosts 137 TMP_KNOWN_HOSTS=$TMP/known_hosts
133 if [ -z "$FLAGS_remote" ]; then 138 if [ -z "$FLAGS_remote" ]; then
134 echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance" 139 echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance"
135 exit 1 140 exit 1
136 fi 141 fi
137 set_up_remote_access 142 set_up_remote_access
138 } 143 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698