This discussion is archived
14 Replies Latest reply: Jun 21, 2011 3:26 AM by Nik RSS

rsync asking for password

DOA Newbie
Currently Being Moderated
Hi experts,

I am on AIX servers .

I want to run rsync from one server to other to synchronize application.

It is working fine. Now I need to set this command on cron to run this script auto every 1 hrs.

Till now I was running this manuall and it was asking for pass, I gave and it's job....

Please suggest a way so that It pick the password auto and do the job for me from cron....


Thanks in ADV
  • 1. Re: rsync asking for password
    Nik Expert
    Currently Being Moderated
    Hi.
    Depending of configuration rsync can use rcp o scp for transport.

    I hope you use scp.

    In this case you need configure ssh for key authirization.

    Short:
    ssh-keygen -t rsa
    Do not enter passprase ( just press enter).
    Transfer *$HOME/.ssh/id_rsa.pub* on second server

    On second server add contents id_rsa.pub to *$HOME/.ssh/authorized_keys*
    cat id_rsa.pub >> $HOME/.ssh/authorized_keys
    Check that rsync work.


    For more: man ssh


    Regards.
  • 2. Re: rsync asking for password
    Dude! Guru
    Currently Being Moderated
    You might want to look into user equivalence and configure a certificate for ssh so it does not prompt for a password as already suggested. But you may have to configure your ssh server accordingly. The below is a cut and paste from one of my previous replies regarding this topic.

    On the server side:

    Edit /etc/ssh/sshd_config and remove the # from the following:

    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys

    Then restart the ssh server:

    /etc/init.d/sshd restart

    Login as the user for whom this is for:

    su - <username>
    mkdir .ssh
    chmod 700 .ssh

    On the client side:

    Run the following command:

    ssh-keygen -t rsa (omit password)

    Then use the following to copy the public key from the client to the
    corresponding login .ssh directory on the server side;

    scp .ssh/id_rsa.pub username@remote_host:.ssh/authorized_keys



    Edited by: Dude on Jun 20, 2011 1:26 AM
  • 3. Re: rsync asking for password
    DOA Newbie
    Currently Being Moderated
    Hi Nik,

    thanks for your promted reply.

    I did:
    orcl2 : 172.17.92.41
    orcl3: 172.17.92.42
    username: appl

    $ ssh-keygen -t rsa

    Generating public/private rsa key pair.
    Enter file in which to save the key (/d05/test/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /d05/test/.ssh/id_rsa.
    Your public key has been saved in /d05/test/.ssh/id_rsa.pub.
    The key fingerprint is:
    c1:5f:f1:56:b6:58:09:20:a5:fc:92:3e:bd:bb:94:b1 appl@orcl2

    Both file created under .ssh

    $ ls
    id_rsa id_rsa.pub

    Transfered this id_rsa.pub from this (orcl2) server to other (orcl3) uder .ssh dir.

    on orcl3 server under .ssh dir. :

    cat id_rsa.pub >>~/.ssh/authorized_keys

    again from orcl2 server try rsync.

    $ rsync -avzu --stats ssh rt appl@172.17.92.42:/d06_test/
    appl@172.17.92.42's password:

    it is still asking fro the password, please suggest if I m making any mistake

    Thanks again!

    Edited by: user9141007 on 20 Jun, 2011 1:59 AM
  • 4. Re: rsync asking for password
    Nik Expert
    Currently Being Moderated
    Hi.
    Please show you file: */etc/ssh/sshd_config*


    Check what write Dude.

    Regards.
  • 5. Re: rsync asking for password
    DOA Newbie
    Currently Being Moderated
    Hi Dude,

    Thanks for the updated prompt.

    Note: source server (orcl2) from where files need to be trns. target server (orcl3) will accept those files

    Removed # from the target server (orcl3).

    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys

    when I am trying to restart ssh on orcl3 by:
    /etc/init.d/sshd restart
    not found

    manually check init.d is not there under /etc

    please suggest !

    Thanks again.
  • 6. Re: rsync asking for password
    Nik Expert
    Currently Being Moderated
    Hi.
    You have AIX system.
    On this forum present who use Solaris and Linux.

    Realy - You need restart sshd daemon.

    Google say that it should be scriptd */etc/rc.d/rc2.d/S70sshd*


    So try:
    /etc/rc.d/rc2.d/S70sshd stop
    /etc/rc.d/rc2.d/S70sshd start


    Regards.
  • 7. Re: rsync asking for password
    DOA Newbie
    Currently Being Moderated
    Hi Nik / Dude,

    Thanks again .

    from the link: http://www.softpanorama.org/Commercial_unixes/AIX/OSS/ssh_on_aix.shtml

    /etc/rc.d/rc2.d/Ssshd stop
    /etc/rc.d/rc2.d/Ssshd start

    and rest done as suggested by Dude.... but no luck still same prompt.

    One confusion, please let me know wheter I need to change/remove # from /etc/ssh/sshd_config from source server OR target server OR both ... becoz all i have done on target server only

    please suggest !
  • 8. Re: rsync asking for password
    Nik Expert
    Currently Being Moderated
    Hi.
    You should edit sshd_config only on target system.

    Please show ls -lad ~/.ssh on both system

    Also Yo can set
    SyslogFacility ; LogLevel and daemon syslog or
    start sshd in debuf mode for trubleshuting.
    Regards

    Edited by: Nik on 20.06.2011 6:19
  • 9. Re: rsync asking for password
    Dude! Guru
    Currently Being Moderated
    Did you create the rsh key on the "client" system and copy it to the server?

    Do the .ssh directory and key file on the server have correct privileges and did you follow the steps as outlined?
  • 10. Re: rsync asking for password
    DOA Newbie
    Currently Being Moderated
    Hi Nik / Dude,

    Dude I have done all steps mentioned by you but no LUCK ......

    Please varify:

    On orcl2 (Client):
    # Removed # from /etc/ssh/sshd_config (Save and Exit)
    # /etc/rc.d/rc2.d/Ssshd stop
    0513-044 The sshd Subsystem was requested to stop.

    # /etc/rc.d/rc2.d/Ssshd start
    0513-059 The sshd Subsystem has been started. Subsystem PID is 3125462.

    $ ssh-keygen -t rsa
    $ chmod 700 .ssh
    $ chmod 600 id_rsa.pub
    $ scp -r id_rsa.pub appl@172.17.92.42:/d06/test/.ssh/

    On orcl3 (target)

    $ mkdir .ssh
    $ chmod 700 .ssh
    $ Use scp command to copy id_rsa_pub file from client to here.
    $ cd .ssh (One think here, authorized_key was not here, so execute below command to create and append content of id_rsa.pub)
    $ cat id_rsa.pub >>~/.ssh/authorized_keys
    $ chmod 600 authorized_keys

    On Orcl2 again:

    rsync -avzu --stats ssh rt appl@172.17.92.42:/d06/test/

    @ Nik,

    ls -lad ~/.ssh from both server:

    orcl2: (source)
    drwx------ 2 test dba 256 Jun 21 10:07 /d05/test/.ssh

    orcl3: (target)
    drwxrwxrwx 2 test dba 256 Jun 21 10:20 /d06/test/.ssh

    Still asking password after doing all ...

    Thank you guys for all your valuable time.
  • 11. Re: rsync asking for password
    Nik Expert
    Currently Being Moderated
    Hi.

    It's problem
    orcl3: (target)
    drwxrwxrwx 2 test dba 256 Jun 21 10:20 /d06/test/.ssh
    Run chmod 700 /d06/test/.ssh and try again.

    Dude write about permissions to .ssh dir.


    Regards.
  • 12. Re: rsync asking for password
    DOA Newbie
    Currently Being Moderated
    Hi Nik,

    I tyied what you suggest !
    On orcl3:
    $ ls -lad
    drwx------ 2 appltest dba 256 Jun 21 10:20 .ssh

    and try to execute again a password less rsync from source but ...... NO :(

    Thanks
  • 13. Re: rsync asking for password
    Dude! Guru
    Currently Being Moderated
    On orcl2 (Client):
    # Removed # from /etc/ssh/sshd_config (Save and Exit)
    You need modify the sshd_config file on the server, orcl3 (172.17.92.42 ?)
    scp -r id_rsa.pub appl@172.17.92.42:/d06/test/.ssh/
    Is /d06/test the default home directory for user appl?
    $ cat id_rsa.pub >>~/.ssh/authorized_keys
    $ chmod 600 authorized_keys
    Instead, on orcl2, please use:

    scp .ssh/id_rsa.pub appl@172.17.92.42:.ssh/authorized_keys
  • 14. Re: rsync asking for password
    Nik Expert
    Currently Being Moderated
    Hi.
    I am confused from your posts.
    It's just copy:


    On orcl3:
    $ ls -lad
    drwx------ 2 appltest dba 256 Jun 21 10:20 .ssh

    orcl3: (target)
    drwxrwxrwx 2 test dba 256 Jun 21 10:20 /d06/test/.ssh

    rsync -avzu --stats ssh rt appl @172.17.92.42:/d06/test/


    What HOME dir for user appl on orcl3 ?

    Who owner of directory ~appl/.ssh on orcl3 ?

    Please show ls -la ~appl/.ssh on orcl3

    Regards.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points