How to give user name and password in a single command to login to remote server

Hello All,

I'm new to unix and i need the below favour from you.

I have list of 50 unix server. I need to login to all the server one by one and with the same user and password. I will declare the user name and password globally in the script.

for example :

servername- hyperV
user name - jack
password - kcaj
ssh jack@hyperV

Using above command till now i login to server and i need to type the password manually

Trouble facing:

Before it prompts password it asking the below

Are you sure you want to continue connecting (yes/no)?

After i give "yes "

then only i asking for password...

so i need this whole to automate.... Please help me:wall:

Torubles facing by

Not sure if this will work but you can give a try.
create a file say file.dat and just type "yes" and passowrd in there like:

echo "yes" > file.dat
echo "passwprd" >> file.dat

Then pass this file to ssh command as below.

ssh jack@hyperV < file.dat

And see if login happens without propmting.

I have tired your option but nogo.It saying the below error and again asking for yes or no ?

"Pseudo-terminal will not be allocated because stdin is not a terminal."

ssh has no option, for security reasons, that allow you to specify the password on the command line, or through redirection from a file. If you need a one-time only script, search this site for an expect solution. If you need to access these servers regularly, use said expect solution to distribute the key for Public Key authentication.

Make ssh-keygen .. Public and private keys.... and then u didn't need enter password for login remote host!!!!

---------- Post updated at 08:18 PM ---------- Previous update was at 08:14 PM ----------

  1. Create key

Press ENTER at every prompt.

linuxconfig.local$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
b2:ad:a0:80:85:ad:6c:16:bd:1c:e7:63:4f:a0:00:15 user@host
The key's randomart image is:
+--[ RSA 2048]----+
|  E.             |
| .               |
|.                |
|.o.              |
|.ooo o. S        |
|oo+ * .+         |
|++ +.+...        |
|o. ...+.         |
|  .   ..         |
+-----------------+
linuxconfig.local$ 

For added security '''the key itself''' would be protected using a strong ''passphrase''. If a passphrase is used to protect the key, ssh-agent can be used to cache the passphrase.
2. Copy key to remote host

linuxconfig.local$ ssh-copy-id root@linuxconfig.org
root@linuxconfig.org's password:

Now try logging into the machine, with "ssh 'root@linuxconfig.org'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
linuxconfig.local$
3. Login to remote host

Note that no password is required.

linuxconfig.local$ ssh root@linuxconfig.org
Last login: Tue Apr  3 12:47:53 2007 from 192.168.0.39
 linuxconfig.org#