I have a small problem here which I wish to describe as an example.OK so here it is .I have a client and a server both UNIX boxes.I wish to run SFTP on the client as user A and authenticate as user B on the server which is going to be accomplished using a script.Se user A is the owner of the script and he authenticates to server as user B .Now the problem is when the authentication happens it asks for a manual password entry which doesn't make sense .I have used ssh rsa keys ..but still no solution as the authentication needs to be automatic.Any solution to the problem is welcome
Are you able to connect to the server via ssh without password? If not, there could be permission problems in ~/.ssh/authorized_keys file. The ssh daemon doesn't allow using that file if it is not well protected from other users. Try the following (assuming the user to be B) on the server where sshd is running:
chmod 750 ~/.ssh/ chown B.root ~/.ssh/ chmod 640 ~/.ssh/authorized_keys chown B.root ~/.ssh/authorized_keys
As suggested in other posts, expect is needed to write scripts using interactive programs like telnet and ftp. I always prefer scp over sftp.
Raghu