passwordless authentication of SFTP script

Dear All
I need to discuss about the problem which has been discussed so many times here. I need to transfer a file from server A to server B via passwordless SFTP script. By reading the threads on this topic here, I followed the below steps but still it's not working ..

Pls find the steps below:
a) Logged in Server An with user Id 'informat' and corresponding passowrd.Home directory is '/opt/informatica'

b) Created the keys in server 'A' with the following command.
/user/local/bin/ssh-keygen -t rsa

c) Copied the public key in id_rsa.pub file under /opt/informatica/.ssh directory of server 'A'

d) Copied the 'id_rsa.pub' file to 'authorized_key' file in /opt/informatica/.ssh directory in serber 'B'

e) Grant 777 privileges to authorized_key file in server 'B'

f) Logged into server 'A' with 'informat' user ID

g) Executed the sftp command for server B
sftp informar@B

h) But it is still prompting for password, where as it should not be because of key based authentication. Can some one pls help me where am I going wrong ..

Thanks in advance

Why did you give 777 permission to authorized_keys?!

Do this:

chmod 644 authorized_keys

Then retry.

HTH

Thanks for your reply . I did the chmod 644, but still it's not working ..:frowning:
Am just wondering whether this will be an issue. I had just 777 in order to give all privelges.

With ssh, the trick is not to give more permissions, but to reduce them! If your .ssh directory or authorized_keys is writable for whole world, then it isn't exactly secure - so ssh will see that and ask you for password.

Check what are the permissions for .ssh directory on A and B. Make them 700 (if not done already) and retry.

Also check the permissions on the homedirectory. Max is 775, better is 755.

Hi
Thanks a lot for clarifying this to me. I check the permission of .ssh folder in both the server. they are 700 and the file id_rsa.pub on server A and authorized_key in sever B have permission 644.
But still it's prompting for password. Do I need to check some settings of Unix box also ..

Hi pjottam
when u say home directory , do u mean the .ssh folder in both server 'A' and 'b' where id_rsa.pub and authrorized_key are residing in source and target respectivly.
If yes the permission of these folders are 700

no, home is the homedirectory. (eg. ~)

Still it's not working !!

What does the ssh-log say on the remote server?
Could you post this?
Second, could you post the output off the following command from the client system (as user informat) to the server system:
ssh -v -v -v B

Hi There
Thanks a lot for helping me out !!!
I am bit novice in Unix, Can u pls tell me where can I get the log of ssh-log
Will be it in server A or B and in which directory ..
I did run a command ssh -v -v -v B
and after that it lists lot of o/p and then prompting for password. I tried to copy the output into the file 'output'. with the below command ..

ssh -v -v -v B > output

But the output file doesn't not contain much. AM I doing something wrong here ..

Thanks a lot for ur effort to help me out !!

Well, it seems to me the output should somewhere say something about offering a key, and failing to do so.

The sshd-log is in your syslog.

It'll say something about the rights of the directory, or about not finding the key.

It could be you need to rename the authorized_keys file to authorized_keys2

Thank you, I was facing same issue, now after changing all permissions it is working fine, i need to set:

chmod -R 700 .ssh/

Hi All,

I need a solution for my issue below.

I have a source and destination, between which i need to connect through SFTP, go to a folder and list files(*.xls) and output that to a file in the destination server location.
We have done this using FTP, but i have to do this through SFTP, I have enabled and put public/private keys in place in both source and destination server.

Please refer to the script that was used with FTP, have to replicate this for SFTP....

ftp -i server_name <<REMOTE_EX
cd folder
ls *.xls temp_ls.dat
bye
REMOTE_EX