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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to give user name and password in a single command to login to remote server
# 1  
Old 01-07-2011
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 :

Code:
servername- hyperV
user name - jack
password - kcaj

Code:
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

Code:
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 meSmilie




Torubles facing by

Last edited by rbatte1; 12-29-2017 at 10:35 AM..
# 2  
Old 01-07-2011
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:
Code:
echo "yes" > file.dat
echo "passwprd" >> file.dat

Then pass this file to ssh command as below.
Code:
ssh jack@hyperV < file.dat

And see if login happens without propmting.
# 3  
Old 01-07-2011
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."
# 4  
Old 01-07-2011
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.
# 5  
Old 01-07-2011
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.
Code:
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

Code:
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.
Code:
linuxconfig.local$ ssh root@linuxconfig.org
Last login: Tue Apr  3 12:47:53 2007 from 192.168.0.39
 linuxconfig.org#


Last edited by pludi; 01-07-2011 at 03:07 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to scp File from root user in one server to say crt user in another server and avoid password?

Can someone help in writing some script through which I can transfer file (scp) from root user in abc server to crt user in hfg server and can give the crt user password in script itself so that it doesn't prompt me every time for password (4 Replies)
Discussion started by: Moon1234
4 Replies

2. HP-UX

Connect to remote server using sftp with password define within command/script

I am trying to connect to remote server in hp-ux, using sftp command (using sftp username@ip and password ) able to connect to remote server but, in this case sftp prompt for password and user need to manually enter it. I want sftp can read a password define in script or from file, so it can... (1 Reply)
Discussion started by: ketanraut
1 Replies

3. Shell Programming and Scripting

How to execute command in remote server without entering password?

Hi, i want to run the command in remote server through ssh and every time when i run the script its asking to enter the password. I dnt want to enter the password, when i enter the ip address and directly the command shuld execute. Script: #!/bin/bash echo "Enter Server IP Address:" read... (2 Replies)
Discussion started by: bapu1981
2 Replies

4. Solaris

how to login with ssh to remote system with out applying the remote root/usr password

how to login with ssh to remote system with out applying the remote root/user password with rlogin we can ujse .rhosts file but with ssh howits possible plz guide (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

5. Shell Programming and Scripting

[SSH] Need to connect to remote server as different user and without password

I have a task requiring that USER_A run a script, which connects to HOST_B as USER_B and does not ask for a password. If I am logged in on HOST_A as USER_B, I can connect to HOST_B without a password, no problem. However, if I try running ssh with the command line "ssh USER_B@HOST_B" while... (3 Replies)
Discussion started by: Totengraber
3 Replies

6. Shell Programming and Scripting

without password to login into remote machine- in the script ??

HI, I need to write a script .. when I run this script , will directly goto that remote machine without asking password.. Once it is entered, I needs to transfer some of the log files... how can I proceed ? (7 Replies)
Discussion started by: hegdeshashi
7 Replies

7. UNIX for Advanced & Expert Users

remote ftp login without password

HI all, I need to post some files on to a clients machine and they said we can ftp without username and password. I do the same as a command line it works ftp <hostname>. but when I do that through a script it asks for user name and pasword. Can any one help me how to do a file ftp. ... (4 Replies)
Discussion started by: umathurumella
4 Replies

8. Shell Programming and Scripting

script that can give login password for "ssh" without involving STDIN

Hi Folks, I am writing a shell script that can logon to remote machine automatically. But, I am facing one problem. I am using "ssh" command in script and while login into remote machine it asks for passowrd and it stops for STDIN input for password. I want my script to supply password... (2 Replies)
Discussion started by: gydave
2 Replies

9. UNIX for Advanced & Expert Users

How to give FTP access to a single user

Hi all, How can i give ftp access to single user on solaris9 system? others should not have the ftp access. i know about ftpusers file in /etc/ftpd but still what about if so many new users are created daily? And now for that single user how can we restict him to ftp the files only from... (2 Replies)
Discussion started by: santhoshkumar_d
2 Replies

10. Shell Programming and Scripting

want to do login to remote server with out password

Hi All I am new to Unix. I have write srcipt which will automate the follwing tasks login to F-Secure server over ssh copy file from my local server to that server. Remote server wants to login with out password(ssh-keygen) I am not getting how to write that scirpt Please help me... (0 Replies)
Discussion started by: prithvi0075
0 Replies
Login or Register to Ask a Question