Bug 1500 - enhance ssh-copy-id to work when login dir on server is not /home/user
Summary: enhance ssh-copy-id to work when login dir on server is not /home/user
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 5.0p1
Hardware: All Linux
: P2 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_6
  Show dependency treegraph
 
Reported: 2008-08-06 03:04 AEST by timothy
Modified: 2011-01-24 12:33 AEDT (History)
2 users (show)

See Also:


Attachments
patchfile which fixes the assumption that after ssh'ing into a machine, the cwd is ~/ (459 bytes, patch)
2008-08-06 03:04 AEST, timothy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description timothy 2008-08-06 03:04:52 AEST
Created attachment 1556 [details]
patchfile which fixes the assumption that after ssh'ing into a machine, the cwd is ~/

ssh-copy-id currently assums that when copying over the key, it is sufficient to check for a .ssh dir at the current location (normally the user's home directory) and then proceed to copy the public key to the .ssh/authorized_keys file, creating the .ssh directory if needed. Under some circumstances, the current working directory of the shell after logging into the server over ssh will *NOT* be the user's home directory, so it can't be assumed that we're always operating in the user's home directory.
As an example, let's say that there is a server that I log in to only to work on documentation. Since every time I log in to that machine, I'll be working in /home/me/documentation, I decide to stick a new line in my ~/.bashrc that simply does a "cd ~/documentation" after initializing aliases and everything else. In this case, when the ssh-copy-id script is run, a new directory ~/documentation/.ssh is created, and my public key is copied to a new file called ~/documentation/.ssh/authorized_keys. Now, as expected, when I try to ssh into the machine, key-based authentication is never attempted and I'm forced to manually move my key over from ~/documentation/.ssh/authorized_keys to ~/.ssh/authorized_keys which defeats the purpose of using ssh-copy-id.
Attached is a patch which fixes this issue.
Thanks!
Comment 1 Damien Miller 2010-06-18 11:09:41 AEST
patch applied, will be in openssh-5.6
Comment 2 Damien Miller 2011-01-24 12:33:44 AEDT
Move resolved bugs to CLOSED after 5.7 release