bugzilla-daemon at bugzilla.mindrot.org
2016-May-30 08:54 UTC
[Bug 2575] New: ssh-copy-id fails when it can not find any key file in ~/.ssh
https://bugzilla.mindrot.org/show_bug.cgi?id=2575 Bug ID: 2575 Summary: ssh-copy-id fails when it can not find any key file in ~/.ssh Product: Portable OpenSSH Version: 7.2p1 Hardware: All OS: Linux Status: NEW Severity: trivial Priority: P5 Component: ssh-copy-id Assignee: unassigned-bugs at mindrot.org Reporter: jjelen at redhat.com Today I run ssh-copy-id from a machine without any generated key (and without any key in ssh-agent) and it failed hard with weird results: /usr/bin/ssh-copy-id: ERROR: failed to open ID file '/root/.pub': No such file or directory (to install the contents of '/root/.pub' anyway, look at the -f option) It is caused by the false expectation, that there are some keys in ~/.ssh/ on the line 59: DEFAULT_PUB_ID_FILE="$HOME/$(cd "$HOME" ; ls -t .ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)" It sets + DEFAULT_PUB_ID_FILE=/root/ which passes the condition + '[' -r /root/ ']' and the execution gets into the function use_id_file() unnoticed and fails to open file /usr/bin/ssh-copy-id: line 87: /root/.pub: No such file or directory' Checking also if the file is regular file should solve the issue. Failing earlier is probably not a good idea, because we can still use ssh-agent keys (remains working). diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id index bef5c95..f750e70 100644 --- a/contrib/ssh-copy-id +++ b/contrib/ssh-copy-id @@ -189,7 +189,8 @@ SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }'$(quote "$USER_HOST")'" # and populate "$@" for later use (only way to get proper quoting of options) eval set -- "$SSH_OPTS" -if [ -z "$(eval $GET_ID)" ] && [ -r "${PUB_ID_FILE:=$DEFAULT_PUB_ID_FILE}" ] ; then +if [ -z "$(eval $GET_ID)" ] && [ -r "${PUB_ID_FILE:=$DEFAULT_PUB_ID_FILE}" ] \ + && [ -f "$PUB_ID_FILE" ] ; then use_id_file "$PUB_ID_FILE" fi -- You are receiving this mail because: You are watching the assignee of the bug.
bugzilla-daemon at bugzilla.mindrot.org
2016-Dec-16 08:45 UTC
[Bug 2575] ssh-copy-id fails when it can not find any key file in ~/.ssh
https://bugzilla.mindrot.org/show_bug.cgi?id=2575 Philip Hands <phil at hands.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |phil at hands.com Blocks| |2647 Assignee|unassigned-bugs at mindrot.org |phil at hands.com Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #1 from Philip Hands <phil at hands.com> --- Thanks for the report, and sorry for taking so long to get round to it. Here's the commit that fixes this: http://git.hands.com/?p=ssh-copy-id.git;a=commitdiff;h=b32a55c8eb4995ef56880682d5ff2eeb9856928d In which I decided to rather make sure that DEFAULT_PUB_ID_FILE remains unset in this case, and then deal with that case. My latest version incorporating that change is here: http://git.hands.com/ssh-copy-id which should work for you, and will hopefully make it's way into OpenSSH in the not too distant future. Cheers, Phil. Referenced Bugs: https://bugzilla.mindrot.org/show_bug.cgi?id=2647 [Bug 2647] Tracking bug for OpenSSH 7.5 release -- You are receiving this mail because: You are watching the assignee of the bug.