Home » Infrastructure » Linux » How to use SCP in non-interactive mode
How to use SCP in non-interactive mode [message #231630] Tue, 17 April 2007 15:05 Go to next message
orasaket
Messages: 70
Registered: November 2006
Member
Hi,
i am using Reh Hat Linux RHEL 4

while copying files from one server to another i am using scp command
however ever time i use scp, it asks me for the password of the server where i am copying the files.

How can i stop this so that i can put my scp in a shell script so as to run silently (non-interactively)

Thanks and Regards,
OraSaket


Re: How to use SCP in non-interactive mode [message #231636 is a reply to message #231630] Tue, 17 April 2007 15:37 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
While logged onto the "local" host, do the following:
$ ssh-keygen - rsa

$# above signifies hitting return key twice to accept defaults
$ scp $HOME/.ssh/id_rsa.pub remote_host:.ssh/authorized_keys2
$#you be prompted for the password on the remote system 1 last time & then never again

HTH & YMMV
Re: How to use SCP in non-interactive mode [message #232198 is a reply to message #231636] Thu, 19 April 2007 15:15 Go to previous messageGo to next message
orasaket
Messages: 70
Registered: November 2006
Member
Hi,

Many thanks for the reply

i tried with what you have suggested but still not getting the results.
I needed this SSH thing so that i will not require to put in the password while using SCP to copy files from server1 to server2 and while logging in with Putty using SSH2

I have tried the following, and tried doing SCP with in new session as well as logging in using Putty but every time i was propmted for password.

Can you suggest me where i am going wrong?

[orsaket@server1 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/orasaket/.ssh/id_rsa): /home/orasaket/.ssh/identity
Created directory '/home/orasaket/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/orasaket/.ssh/identity.
Your public key has been saved in /home/orasaket/.ssh/identity.pub.
The key fingerprint is:
de:03:c0:e1:e4:f1:89:f6:0d:93:44:66:7c:42:f1:95 orasaket@server1.abc.co.uk

[orasaket@server1 ~]$ cp /home/orasaket/.ssh/identity.pub authorized_keys


[orasaket@server1 ~]$ cp authorized_keys ./.ssh/

 [orasaket@server1 ~]$ scp -p ~/.ssh/authorized_keys server2:.ssh/
 Here i was asked for server2 password



Thanks and Regards,
OraSaket
Re: How to use SCP in non-interactive mode [message #232200 is a reply to message #231630] Thu, 19 April 2007 15:26 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
THANK YOU for the actual CUT & PASTE of what you really did.
Contrary to what you think/thought you did NOT do as directed.

Please compare the following with what you really did:
$ scp $HOME/.ssh/id_rsa.pub    remote_host:.ssh/authorized_keys2

you WILL be prompted for password to complete this "scp".
then if you do
scp $HOME/.ssh/id_rsa.pub remote_host:/tmp
the copy should proceed without you being prompted for password.

PEBKAC!

[Updated on: Thu, 19 April 2007 15:29] by Moderator

Report message to a moderator

Re: How to use SCP in non-interactive mode [message #232373 is a reply to message #231630] Fri, 20 April 2007 05:50 Go to previous messageGo to next message
orasaket
Messages: 70
Registered: November 2006
Member
No Luck!!

I have tried following
[orasaket@server1 .ssh]$ scp $HOME/.ssh/identity.pub server2:.ssh/authorized_keys2
orasaket@server2's password:
identity.pub                                                                                                                100%  236     0.2KB/s   00:00
[orasaket@server1 .ssh]$
[orasaket@server1 .ssh]$ scp $HOME/.ssh/identity.pub server2:/tmp
orasaket@server2's password:
identity.pub                                                                                                                100%  236     0.2KB/s   00:00
[orasaket@server1 .ssh]$


Even i tried openening new session after this but still it asks me for the password

[orasaket@server1 ~]$ scp abc server2:/home/orasaket
orasaket@server2's password:


Please suggest

Thanks and Regards,
OraSaket
Re: How to use SCP in non-interactive mode [message #232474 is a reply to message #231630] Fri, 20 April 2007 12:14 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Please suggest
I suggest you actually follow my two previous posts.
You're On Your Own
Previous Topic: Oracle client installation problem
Next Topic: how to do database automatic startup and shutdown
Goto Forum:
  


Current Time: Thu Mar 28 13:44:23 CDT 2024