tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
tom | 1a2908c | 2014-09-23 16:37:39 -0700 | [diff] [blame] | 3 | # Pushes the local id_rsa.pub to the authorized_keys on a remote ONOS node. |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | remote=$ONOS_USER@${1:-$OCI} |
| 10 | |
Brian O'Connor | e8c7b08 | 2015-06-11 00:06:50 -0700 | [diff] [blame] | 11 | cat ~/.ssh/id_rsa.pub | ssh $remote " |
Marc De Leenheer | 8c02cfc | 2014-12-02 11:40:21 -0800 | [diff] [blame] | 12 | mkdir -p ~/.ssh |
Jonathan Hart | b4317d7 | 2015-03-27 13:37:56 -0700 | [diff] [blame] | 13 | chmod 700 ~/.ssh |
Brian O'Connor | e8c7b08 | 2015-06-11 00:06:50 -0700 | [diff] [blame] | 14 | cat >> ~/.ssh/authorized_keys |
tom | 2228803 | 2014-10-07 08:16:53 -0700 | [diff] [blame] | 15 | sort -u ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.bak |
| 16 | mv ~/.ssh/authorized_keys.bak ~/.ssh/authorized_keys |
Jonathan Hart | b4317d7 | 2015-03-27 13:37:56 -0700 | [diff] [blame] | 17 | chmod 600 ~/.ssh/authorized_keys |
tom | 2228803 | 2014-10-07 08:16:53 -0700 | [diff] [blame] | 18 | " |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 19 | ssh -n -o PasswordAuthentication=no $remote true |