blob: 94da6998058a6796c58631f4653d50b2746fc0f5 [file] [log] [blame]
tom2d7acb72014-09-22 22:13:00 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom1a2908c2014-09-23 16:37:39 -07003# Pushes the local id_rsa.pub to the authorized_keys on a remote ONOS node.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom2d7acb72014-09-22 22:13:00 -07005
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
9remote=$ONOS_USER@${1:-$OCI}
10
Brian O'Connore8c7b082015-06-11 00:06:50 -070011cat ~/.ssh/id_rsa.pub | ssh $remote "
Marc De Leenheer8c02cfc2014-12-02 11:40:21 -080012 mkdir -p ~/.ssh
Jonathan Hartb4317d72015-03-27 13:37:56 -070013 chmod 700 ~/.ssh
Brian O'Connore8c7b082015-06-11 00:06:50 -070014 cat >> ~/.ssh/authorized_keys
tom22288032014-10-07 08:16:53 -070015 sort -u ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.bak
16 mv ~/.ssh/authorized_keys.bak ~/.ssh/authorized_keys
Jonathan Hartb4317d72015-03-27 13:37:56 -070017 chmod 600 ~/.ssh/authorized_keys
tom22288032014-10-07 08:16:53 -070018"
tom2d7acb72014-09-22 22:13:00 -070019ssh -n -o PasswordAuthentication=no $remote true