ssh - passing password in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh - passing password in shell script
# 1  
Old 08-14-2007
ssh - passing password in shell script

I have a requirement, I need to run a command at remote system using a ssh. Is there any way we can pass the username and password in shell script to the ssh command as we did it in one of the shell script for FTP.

ftp -n $i <<!EOF >>
user Username $PASSWD
cd /home/scripts
get $FILE\_up\_test
bye
!EOF


-----
My problem is I can't use rsh.

Is there any simple way other then using RSA based public and private keys- its bit tuff.
# 2  
Old 08-14-2007
Quote:
Is there any simple way other then using RSA based public and private keys- its bit tuff.
Actually this is quite easy.

Keys need to be generated and public keys to be exchanged.

Then you are ready to use passwordless ssh.

There are many threads in the forum discussing the same you could search for them.
# 3  
Old 08-14-2007
Lightbulb ssh

i know if you use ssh username@ip.addr it will prompt for the password and bypass the username. I would like to know how to bypass the password as wellSmilie
# 4  
Old 08-14-2007
Quote:
Originally Posted by michaelnas
i know if you use ssh username@ip.addr it will prompt for the password and bypass the username. I would like to know how to bypass the password as wellSmilie
What I suggested is not for a ssh which prompts for a password

If you generate keys in two hosts for which passwordless ssh is to be enabled and if public keys swapped in .ssh directory of the host, then passwordless ssh can be enabled
# 5  
Old 02-14-2008
I can't enable PubkeyAuthentication to work

Hi,

I have followed all the steps setting up authentication keys for client and server. I have it working in one connection with a remote server. I have sent the same public key to another remote server but everytime I try to connect, the password prompt is coming up.

I have changed the permissions of the folders and files but to no avail. The only thing I haven't tried is to change the permission of the remote server's home directory. It is a shared home directory so I'm reluctant to change it. Would this be what's causing the problem? I have also checked the ssh.config and sshd.config for PubkeyAuthentication, all seems to be ok with 'yes'. Here is the debug of my attempted connection.
Code:
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/onp/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/onp/.ssh/id_dsa
debug1: Trying private key: /home/onp/.ssh/identity
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
ftp_Trus@ftp_tlm_prd's password:

I hope someone could help me out.

Mar11B

Last edited by Yogesh Sawant; 08-11-2010 at 02:25 AM.. Reason: added code tags
# 6  
Old 05-05-2009
Hi,

Try the below code.

Code:
 
#!/bin/sh
ftp hostname <<END_SCRIPT
quote USER <username>
quote PASS <password>
cd /home/scripts
get $FILE\_up\_test
bye
END_SCRIPT
exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing Username & password through shell script to java code

Hi, I have a shell script (script.sh) in which we are calling java code which asks for Username: Password: for authentication purpose currently we are passing the credential manually and run the script. but I am trying echo -e "user_id\npassword" | script.sh but its not... (1 Reply)
Discussion started by: rakeshtomar82
1 Replies

2. Shell Programming and Scripting

Ssh to 100s of hosts with password in a shell script or text file

I have about 500 hosts where I need to ssh by sending the password on the command line or in a text file in a clear text . However I am not able to download "sshpass" or other tools . Any other ways to pass the password in a script ? (3 Replies)
Discussion started by: gubbu
3 Replies

3. Shell Programming and Scripting

Passing password with SSH command

Hi Experts, I have specific requirement where I want to pass the password with the ssh username@hostname command . I dont want to use RSA public and private keys also. Because that will be on production server and no one wants to give access like that. Second thing it is production... (14 Replies)
Discussion started by: sharsour
14 Replies

4. Shell Programming and Scripting

Passing password for ssh in Script

I want to do following 2 commands via script: 1) eval `ssh-agent`2) ssh-add /export/home/sufuser/.ssh/id_rsa When asked for passphrase enter "passwordpassword1234 but whenever I run the script it stucks after "ssh-add /export/home/sufuser/.ssh/id_rsa" command and asks fro... (4 Replies)
Discussion started by: yogeshpawar
4 Replies

5. Shell Programming and Scripting

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 (4 Replies)
Discussion started by: ss135r
4 Replies

6. Shell Programming and Scripting

Passing password in script for ssh connection - no except

Used the script posted on forum - unix.com/shell-programming-scripting/21597-script-change-passwords-same-user-multiple-servers.html but the last question posted on this seems to be still unanswered, tried different things with no success, can someone help giving an way to pass the password via... (5 Replies)
Discussion started by: sapadmin
5 Replies

7. Shell Programming and Scripting

when i use ssh in my shell script it will promt for a password :(

when i use ssh in my ssh in my shell script it is promt for the password my command is ssh user@server ls -l >log.txt can some one suggest if i am doing wrong. i dont want the script will prompt for a password promt. my requirement is the shell script will take the password inside the... (2 Replies)
Discussion started by: alokjyotibal
2 Replies

8. Shell Programming and Scripting

passing database password to isql command in shell script

Hi, I need to connect to DB through my shell script. but I dont want to hardcode my db password in the script. Is there a way to do it? Thanks ---------- Post updated at 07:42 PM ---------- Previous update was at 04:54 PM ---------- :(Guys..please help me with this:( (1 Reply)
Discussion started by: agrawal.prachi
1 Replies

9. Shell Programming and Scripting

SSH Login by passing password.

ssh/sftp login by passing password , is it possible.Don't want to expect. (1 Reply)
Discussion started by: dinjo_jo
1 Replies

10. Shell Programming and Scripting

passing password in shell script

Hi, Anybody help to write a shell script as below requirement. script stops some costomized application services. 1. first it will stop apache as root 2. then it will switch to my application user and stop app service. Note: passing password is required to stop app service as app... (1 Reply)
Discussion started by: manojbarot1
1 Replies
Login or Register to Ask a Question