how to Pass , Password for ssh in linux without using sshpass or expect package


Can I pass password while performing ssh in linux. If I dont have to use packages like sshpass and expect. Is there any way to use ssh where I can pass the password for remote host.

Shweta AgarwalSenior AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joy DingenenICT system consultantCommented:

you could just use
on the source:
ssh-copy-id user@target

Open in new window

after that the ssh session will be on key-pair authentication (only with that user ofc).

Hope that helps,
Rajat SehgalFounder Enhance TechnologyCommented:
Create Public and private key using ssh-keygen
#ssh-keygen -t rsa
It will ask for the location to save the key
Default location : /root/.ssh/id_rsa
Next It will ask passphrase. (u can do it without a password also, for that just enter )
It will create Private key and public key. See the out put
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
ssh-keygen -t rsa

Upload public key to the server which you want to upload
#ssh-copy-id -i /root/.ssh/ root@
(Here is a example ip address)
It will automatically copy your public key to .ssh/authorized_keys

You can upload the public key to multiple servers using same command ( ssh-copy-id ). Next time onwards the server will not ask the user ID and password

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joy DingenenICT system consultantCommented:
We both said the same
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.