Ssh via bash

Good day!
I going to create bash script for connecting remote machine using ssh.

$SHELL -version
GNU bash, version 4.2.10(1)-release (x86_64-suse-linux-gnu)

I had write :

ssh $ssh_user@$ssh_dest
expect “?assword:*”
send – “$ssh_pass\r”

but “expect” command don’t performs. I found sshpass application and it works fine, but I would know is my code right & is here alternatively method for expecting ?

If you want to login to remote boxes without having to type passwords, you should use Public Key / Private Key (Public Key Cryptography / PKI)

Here’s a rough guide:

I’ve been doing that for years.

However, as another responder suggested, you should use public key authentication. That’s what I use. It works well.

Same here. Get public key authentication working first, then create a script. My ~/bin/thuis does this. Habit is to do this (even if the remote allows this) never ever as root, but connect first, then use ‘su -c yast’ f.e.