2 ##############################################################################
3 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 #this script is copied from https://github.com/guioconnor/Passwordless-SSH.
12 #the Bottlenecks project needs to set the machines login each other passwordless, this script is appropriate.
27 # Read the host and username to store public key (the host/username accepting passwordless ssh from this computer)
28 echo "What host you want to grant passwordless SSH from this computer?"
30 echo "What is your username on $hostname? ($USER?)"
41 if [ -f $path/$filename ]
43 echo "RSA key exists on $path/$filename, using existing file"
45 ssh-keygen -t rsa -f "$path/$filename"
46 echo RSA key pair generated
49 echo "We need to log into $hostname as $username to set up your public key (hopefully last time you'll use password from this computer)"
50 cat "$path/$filename.pub" | ssh "$hostname" -l "$username" '[ -d .ssh ] || mkdir .ssh; cat >> .ssh/authorized_keys; chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys'
55 echo "Set up complete, try to ssh to $host now"
58 echo "an error has occured"