Operating System - Linux
1748180 Members
4234 Online
108759 Solutions
New Discussion юеВ

help needed on ssh and scp in shell scripting

 
Karthik_sg
Frequent Advisor

help needed on ssh and scp in shell scripting

hey guys,
i have few rpms on my system.th eproblem is that i have to copy these rpms to another system whose ip is say 12.0.0.34.and i have to run the rpm there.it is usually for updating.i want to use ssh and scp command but again whn using these i have supply the password in my script itself.sum pls tel me how to do this.my machines ip may be 12.0.0.13.thnks in advance.
6 REPLIES 6
Alexander Chuzhoy
Honored Contributor

Re: help needed on ssh and scp in shell scripting

You can copy your publick ssh key to the destination and you won't be promted for password. To do that:
1. run `ssh-keygen -d` on you source machine.
2. copy the file ~/.ssh/id.dsa_pub username@remotehost:/tmp/
3. login to remote machine.
4. run `cat /tmp/id.dsa_pub >> ~/.ssh/authorized_keys`
5. remove the public key from tmp `rm /tmp/id.dsa_pub`.
6.logout from remote machine and try to login there via ssh - you shouldn't be prompted for password anymore...
Karthik_sg
Frequent Advisor

Re: help needed on ssh and scp in shell scripting

thnks for ur reply sir,bt i am nt sure and aware wht public keys are,if u can tell me indetail with the code it wil be ver helpful
Ivan Ferreira
Honored Contributor

Re: help needed on ssh and scp in shell scripting

Alexander Chuzhoy already sent the code!! You have to run those commands to get public key without password authentication.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Karthik_sg
Frequent Advisor

Re: help needed on ssh and scp in shell scripting

hey i tried runnin the code but it asks for sum passwd.I am not sure how to go about it still.coz if i give my sustem or the destination system password,its not accepting.can u explain whata public key is?
Victor Semaska_3
Esteemed Contributor

Re: help needed on ssh and scp in shell scripting

You're talking about it asking for the passphsare, right? Like this:

Enter passphrase (empty for no passphrase):

Simple press .

Vic
There are 10 kinds of people, one that understands binary and one that doesn't.
Karthik_sg
Frequent Advisor

Re: help needed on ssh and scp in shell scripting

yes.My objective is to install a rpm on a machine in the same network thru shell script.but is i use ssh it asks for a password and the control is entirely given out until we exit whch thn returns the control back to shell script.i hope u understand.so how to go abt it