SuSE Scripting Automation: Fully Automatic Login

Look! No Password!

A little tid-bit that will help you set up fully automatic access without using a password and will work great for scripting! If you are running scripts on an array of servers and want to use a low overhead method, this is the way to get multiple bangs for your buck!

On the "server" machine.

  1. Enter the .ssh directory
    cd .ssh
  2. If the directory does not exist create it
    mkdir .ssh
  3. ssh-keygen -t rsa
  4. cat >> authorized_keys
  5. chmod 600 authorized_keys
  6. rm

On the "client" machine.

  1. cd .ssh
  2. scp ip_of_your_server:.ssh/id_rsa ip_of_your_server.rsa
  3. chmod 600 ip_of_your_server.rsa
  4. Add your server to the ssh config file:
    echo "Host ip_of_your_server" >> config
  5. echo "IdentityFile ~/.ssh/ip_of_your_server.rsa" >> config

Now Test the setup from the client.

  1. ssh ip_of_your_server
  2. scp file ip_of_your_server:.

Using it within a Bash script.

# Define you servers
server_names() {
        echo -en "IP_of_your_Server"

# Loop through servers and save outout into a report
for srv_name in $(server_names)
            echo -e "\nServer: $srv_name"
            ssh USER@$srv_name "Do Commands" | while read -a REPORT_OUT

Peace be unto you. Thank you for visiting!