Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Secures the ONOS console for all instances in the cell ONOS cluster. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) |
| 10 | |
| 11 | for node in $nodes; do |
Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 12 | # Prune the node entry from the known hosts file since server key changes |
| 13 | ssh-keygen -f "$HOME/.ssh/known_hosts" -R [$node]:8101 |
| 14 | |
| 15 | # Setup passwordless login for the local user on the remote node |
| 16 | ssh $ONOS_USER@$node " |
| 17 | [ ! -f ~/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' -q |
| 18 | $ONOS_INSTALL_DIR/bin/onos-user-key \$(id -un) \$(cut -d\\ -f2 ~/.ssh/id_rsa.pub) |
Thomas Vachuska | eff0e4e | 2015-08-11 00:26:24 -0700 | [diff] [blame] | 19 | $ONOS_INSTALL_DIR/bin/onos-secure-ssh "$@" |
Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 20 | |
| 21 | # Implicitly accept the new server key in dev/test environments |
| 22 | while ! ssh -p 8101 -o StrictHostKeyChecking=no localhost list 2>/dev/null; do |
| 23 | echo Waiting for connection... |
| 24 | sleep 1 |
| 25 | done |
| 26 | " |
Charles Chan | 2497dbe | 2015-10-14 17:08:56 -0700 | [diff] [blame] | 27 | |
| 28 | # Setup passwordless login for the remote user on the local bench host |
| 29 | # For now, we let the local public key override the remote one |
| 30 | # TODO: fix username collision between workbench and the remote hosts |
| 31 | onos-user-key $node |
Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 32 | done |
| 33 | |