-
Notifications
You must be signed in to change notification settings - Fork 29
/
setup-autologin
executable file
·39 lines (32 loc) · 1.23 KB
/
setup-autologin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
###############################################################################
# This script will setup auto-login into a remote machine. Specifically,
# this is is useful for seting up auto-login for the Naos.
# Instructions filtched from http://linuxproblem.org/art_9.html
#
# NOTE: If you run this script twice on the same robot, your hostname will
# appear twice in .ssh/authorized_keys. Login will still work, but you will
# bloat the file
#
# jstrom, June 2008
#
##############################################################################
REMOTE_USERNAME=root
SSH=~/.ssh
ID_RSA_FILE=$SSH/id_rsa
RSA_PUBLIC_KEY_FILE=$SSH/id_rsa.pub
if [ "$1" == "" ]; then
echo "Usage: ./setup-autologin <robot-ip>"
exit 1
fi
echo "Configuring auto login. Only run this once per robot "
if [ ! -e $RSA_PUBLIC_KEY_FILE ] || [ ! -e $ID_RSA_FILE ]; then
echo "Generating a public key"
ssh-keygen -t rsa -N "" -f $ID_RSA_FILE
else
echo "Detected an exisiting public key, so won't generate a new one"
fi
echo "Configuring remote robot with your public key."
echo "Please enter the password for the robot when promted:"
cat $RSA_PUBLIC_KEY_FILE | ssh $REMOTE_USERNAME@$1 'mkdir -p .ssh && cat >> .ssh/authorized_keys'
echo "setup complete"