Connect through SSH and type in password automatically, without using a public key

There is a linux utility called sshpass. It allows you to do exactly what you want and will take a server password either as a command line argument, or from a file (i prefer this way, so i do not have my server password show up in shell history) and you use it like so:

sshpass -f file_with_password ssh user@server ls -la

This will ssh into a server and run ls -la. One thing, however, you have to manually ssh into a server first (if you haven't done so already), so the server gets added to your ~/.ssh/known_hosts. If you don't do that, sshpass will not work.


You can use Expect to do this. Obviously, this isn't preferable from a security standpoint, because it will require you to use a script that contains your password in plaintext. (But I won't belabor that point since you said in your question that you plan to use public key authentication as soon as possible!)