When I login to server with a key
ssh -i /home/me/.ssh/id_rsa server
everything goes without glitch. The key is authorized on the server. However if I try to do same from a shell script, I get a password request. Same happens when I try to scp using the keyfile:
scp -i /home/me/.ssh/id_rsa file server:
I have also created ~/.ssh/config for the host:
Host server
hostname server
IdentityFile /home/me/.ssh/id_rsa
When I try to SSH in just with ssh server
I also get a password request. The keyfile, ssh config and server's authorized_keys have privileges set to 600.
What can I do to resolve this?
EDIT
Same also happens with sshfs.
sshfs -o IdentityFile=/home/me/.ssh/id_rsa server:/directory mountpoint
from cli works fine. When it's in a shell script, I get a password request.