'prepmod'-wrap 'lufsd' instead of 'lufsmnt' as 'prepmod' fail is safe this way.
[lufs.git] / lufsd / lussh
1 #!/bin/sh
2
3 echo
4 echo This script will help you setup ssh public key authentication.
5
6
7
8 host=dummy
9     
10 while [ -n "$host" ]; do 
11 echo -n "SSH server: "
12 read host
13 if [ -n "$host" ]; then
14     echo -n "user[$USER]: "
15     read usr
16     if [ -z "$usr" ]; then
17         usr=$USER
18     fi
19             
20     echo "Setting up RSA authentication for ${usr}@${host}..."      
21     if [ -f ~/.ssh/id_rsa.pub ]; then 
22         echo "RSA public key OK." 
23     else 
24         ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ""
25     fi
26     scp ~/.ssh/id_rsa.pub ${usr}@${host}:~/
27     ssh ${usr}@${host} "if [ ! -d ~/.ssh ]; then
28                                 mkdir ~/.ssh
29                             fi
30                             cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
31                             chmod 0600 ~/.ssh/authorized_keys
32                             rm ~/id_rsa.pub" 
33     echo
34     echo "You should see the following message without being prompted for anything now..."
35     echo
36     ssh ${usr}@${host} "echo !!! Congratulations, you are now logged in as ${usr}@${host} !!!"
37     echo
38     echo "If you were prompted, public key authentication could not be configured..."
39                                 
40             echo
41             echo "Enter a blank servername when done."      
42             echo
43 fi      
44 done
45
46 echo "End of configuration."