You Wang | 11ce5f0 | 2017-01-24 17:37:44 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | |
| 3 | # Copyright 2017 Open Networking Foundation (ONF) |
| 4 | # |
| 5 | # Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 6 | # the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 7 | # or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 8 | # |
| 9 | # TestON is free software: you can redistribute it and/or modify |
| 10 | # it under the terms of the GNU General Public License as published by |
| 11 | # the Free Software Foundation, either version 2 of the License, or |
| 12 | # (at your option) any later version. |
| 13 | # |
| 14 | # TestON is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | # GNU General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License |
| 20 | # along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
You Wang | 11ce5f0 | 2017-01-24 17:37:44 -0800 | [diff] [blame] | 22 | # ------------------------------------------------------------------------ |
| 23 | # This script is a workaround for the key collision issue when loging into |
| 24 | # onos cli from both test-station and onos cells with identical user names. |
| 25 | # It copies both private and public keys of localhost (test-station) to |
| 26 | # all remote hosts specified in your cell. |
| 27 | # It also backs up the original keys of the remote hosts before |
| 28 | # overwriting them. |
| 29 | # Setting up passwordless login is recommended before running the script. |
| 30 | # ------------------------------------------------------------------------ |
| 31 | |
| 32 | ADDRESSES=() |
| 33 | # Check if OC1 to OC7 exist |
| 34 | for i in $(seq 1 7); do |
| 35 | if [ -n "$OC$i" ]; then |
| 36 | TEMP=OC$i |
| 37 | ADDRESSES+=(${!TEMP}) |
| 38 | fi |
| 39 | done |
| 40 | |
| 41 | # Check if OCN exists |
| 42 | [ -n "$OCN" ] && ADDRESSES+=($OCN) |
| 43 | |
| 44 | # Copy keys to remote hosts |
| 45 | for address in "${ADDRESSES[@]}"; do |
| 46 | echo "Backing up remote keys on" $address |
| 47 | ssh sdn@$address "cd ~/.ssh; \ |
| 48 | cp id_rsa id_rsa.old; \ |
| 49 | cp id_rsa.pub id_rsa.pub.old; " |
| 50 | |
| 51 | echo "Copying keys to" $address |
| 52 | scp ~/.ssh/id_rsa sdn@$address:~/.ssh/ |
| 53 | scp ~/.ssh/id_rsa.pub sdn@$address:~/.ssh/ |
| 54 | done |