Created attachment 2543 [details] Possible patch to copy key into home folder (instead of current directory) On the server, I configure my user to change the current directory upon login. For example, I add the command "cd /path/to/project" in my ~/.bashrc. Then, on the client, if I try to "ssh-copy-id user@myserver", it will run smoothly (identifies that it need to add new key, ask for password, says it added the key and ask to try to login), but when I try to login, it will keep asking for password. If I try to execute ssh-copy-id again it keeps identifying that the key need to be added (as if it was not added before). I verified permissions, and they are correct. I found out that the directory "/path/to/project/.ssh" was created, as was an "authorized_keys" file inside it, containing multiple repeated lines of my public key (one for each of the attempts of issuing ssh-copy-id). By looking into ssh-copy-id's source script, I could see that it assumes it is already in the home folder, and appends the new keys into ".ssh/authorized_keys". Shouldn't it be appended to "~/.ssh/authorized_keys"?
That's odd, since I just tried to reproduce the problem, and with a cd in my ~/.bashrc, interactive logins end up in another directory, but commands seem to be run in the homedir. Could you mention which versions of software you're getting this effect with? Anyway, I don't suppose adding a 'cd' command at the start would do any harm, so maybe I'll do that anyway.
I've just tested ssh-copy-id (openssh 7.1p1) to copy my key to a different server than I tried before, and it worked fine. Then, I guess it's probably some weird behaviour of the server. Anyway, I think it might be a good idea for ssh-copy-id to cover these cases. You propose to add a "cd ~". Why not just reference the authorized keys file as "~/.ssh/authorized_keys"?
I had a feeling that cd without a parameter taking you home was a feature before ~ was, but I'm probably remembering something awful from the 80s, like Xenix, which hopefully means we don't have to care any more. BTW Am I right in thinking that you're no longer able to reproduce this anyway? If not, and you still have access to the failing system, please try the latest version from here: http://git.hands.com/ssh-copy-id and tell me if that fixes the problem for you. Cheers, Phil.
Close all resolved bugs after 7.3p1 release