Passing Password to SSH without using expect in a Script

How can I pass password in SSH command without using expect in a shell program.
I don't have expect installed on my Solaris server.
#!/bin/bash
ssh user@hotname (how to supply pass in script?:wall:)

Experts please help its very urgent.

Shrawan Kumar Sahu

You can't, and this isn't a bug, it's a feature to prevent anyone on the same machine from getting at your password. Using expect to circumvent this is already a very bad idea in my opinion.

If you don't want to enter a password, use public key authentication.

Thanks for quick response.
I have never used public key authentication. Can you please give me an example on how to use it in SSH script.

Appreciate you help.

Thanks,
Shrawan

Use man ssh-keygen (OpenSolaris) to create a key pair and ssh-copy-id to copy the public key to another machine. From that point on ssh will automatically try to authenticate using the private key on the local machine.

Thank :slight_smile: you very much for the info.
I will be required to study those commands, will get back to you if I face any problem.
:b: