bash ssh login script

hello
anyone have done ssh login script without "expect"
(automatic login from host A / user b to Host B / user b without enter any passwords)?
cheers

Basically you don't need a script for that. Create a public key with an empty pass-phrase on host A, put it into the user's ~/.ssh/authorized_keys of the host B and you will be able to do ssh or scp to B without being prompted for a password.
If you write a script where you implement this, the option "batchmode" comes in handy sometimes.

"man ssh" or Google for more info.

maybe i missing something
i ran this script:

#!/bin/bash
if [ ! -r ${HOME}/.ssh/id_rsa.pub ]; then
ssh-keygen -b 2048 -t rsa
fi
#Append to the copy on the remote server
cat ~/.ssh/id_rsa.pub | ssh ${USER}@$1 "cat - >> .ssh/authorized_keys"

if [ $? -eq 0 ]; then
echo "Success"
fi

and still could not login automatcly to the host server
why?