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

Hi,


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.



Thanks
Shweta AgarwalAutomation EngineerAsked:
Who is Participating?
 
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/id_rsa.pub.
ssh-keygen -t rsa

Upload public key to the server which you want to upload
#ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.0.1
(Here 192.168.0.1 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
0
 
Joy DingenenICT system consultantCommented:
Hello,

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,
Joy
0
 
Joy DingenenICT system consultantCommented:
We both said the same
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.