Shell Script - Automatically SSH Without Key

If you ever need to write a script that automatically SSHs to another computer, use this script. You'll find that you cannot automatically SSH for two reasons.

  1. You can't pass the password through the ssh command
  2. You can't bypass the initial ssh key registration

This script can handle both these problems.

It requires the expect package, which is installed by default on OS X and most Linux distros.


spawn ssh username@hostname - o StrictHostKeyChecking=no
expect "Password:"
send "passwordr"

Write a Comment