blob: 3c15fa3c7a177e324a2347f6a9d2eb8792161fe2 [file] [log] [blame]
Thomas Vachuska12bf4452015-06-26 09:15:38 -07001#!/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
9nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
10
11for node in $nodes; do
12 # Setup passwordless login for the remote user on the local bench host
13 onos-user-key $node
14
15 # Prune the node entry from the known hosts file since server key changes
16 ssh-keygen -f "$HOME/.ssh/known_hosts" -R [$node]:8101
17
18 # Setup passwordless login for the local user on the remote node
19 ssh $ONOS_USER@$node "
20 [ ! -f ~/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' -q
21 $ONOS_INSTALL_DIR/bin/onos-user-key \$(id -un) \$(cut -d\\ -f2 ~/.ssh/id_rsa.pub)
Thomas Vachuskaeff0e4e2015-08-11 00:26:24 -070022 $ONOS_INSTALL_DIR/bin/onos-secure-ssh "$@"
Thomas Vachuska12bf4452015-06-26 09:15:38 -070023
24 # Implicitly accept the new server key in dev/test environments
25 while ! ssh -p 8101 -o StrictHostKeyChecking=no localhost list 2>/dev/null; do
26 echo Waiting for connection...
27 sleep 1
28 done
29 "
30done
31