I had mounted my shared folder with this command (saved in
/etc/rc.local in order to mount the folder on system start automatically):
mount -t vboxsf -o uid=1000,gid=1000 sshkeys /root/.ssh
Now I've changed the user, the usergroup, and the access rights of the mounted folder in the mount commando:
mount -t vboxsf -o uid=0,gid=0,umask=077 sshkeys /root/.ssh
P.S. For everyone, who has participated in this discussion:
Since the thread became a bit chaotic, I would like to summarize it:
At first I had the problem, that I could not use my keys, when they came from a shared folder (
Bad owner or permissions... error). The corollary for me was, that there were two ways: (a) either to set the user, group and the access rights for the folder how the SSH client (?) needs or (b) to make it ignore its access rights restrictions. Since I could not apply
chmod to my shared folder and thought, it were not possible to change the access rights for it, I saw (b) as the last possibility to resolve the issue -- and changed the question/title. It was a mistake and I've just made this change back.
To the discussion about the security: I'm working as root (on my dev VM!) and it's a deadly sin for every safety-conscious user. Actually I also think, that normally one should not log in as root. But I hold the opinion, that it doesn't apply to the case of a dev virtual machine. Anyway -- it is an offtopic, since it has nothing to do with the issue, I've described. This issue can occur for every user of every usergroup.