8Permission is granted to copy and distribute modified versions of this 9manual under the conditions for verbatim copying, provided that the 10entire resulting derived work is distributed under the terms of a 11permission notice identical to this one. 12 13Permission is granted to copy and distribute translations of this 14manual into another language, under the above conditions for modified 15versions, except that this permission notice may be included in 16translations approved by the Free Software Foundation instead of in 17the original English.
| 13THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26.SH DESCRIPTION 27.BR ssh-copy-id 28is a script that uses ssh to log into a remote machine and 29append the indicated identity file to that machine's 30.B ~/.ssh/authorized_keys 31file. 32.PP 33If the 34.B -i 35option is given then the identity file (defaults to 36.BR ~/.ssh/id_rsa.pub ) 37is used, regardless of whether there are any keys in your 38.BR ssh-agent . 39Otherwise, if this: 40.PP 41.B " ssh-add -L" 42.PP 43provides any output, it uses that in preference to the identity file. 44.PP 45If the 46.B -i 47option is used, or the 48.B ssh-add 49produced no output, then it uses the contents of the identity 50file. Once it has one or more fingerprints (by whatever means) it 51uses ssh to append them to 52.B ~/.ssh/authorized_keys 53on the remote machine (creating the file, and directory, if necessary.) 54 55.SH NOTES 56This program does not modify the permissions of any 57pre-existing files or directories. Therefore, if the remote 58.B sshd 59has 60.B StrictModes 61set in its 62configuration, then the user's home, 63.B ~/.ssh 64folder, and 65.B ~/.ssh/authorized_keys 66file may need to have group writability disabled manually, e.g. via 67 68.B " chmod go-w ~ ~/.ssh ~/.ssh/authorized_keys" 69 70on the remote machine. 71 72.SH "SEE ALSO" 73.BR ssh (1), 74.BR ssh-agent (1), 75.BR sshd (8)
| 41.Sh DESCRIPTION 42.Nm 43is a script that uses 44.Xr ssh 1 45to log into a remote machine (presumably using a login password, 46so password authentication should be enabled, unless you've done some 47clever use of multiple identities). It assembles a list of one or more 48fingerprints (as described below) and tries to log in with each key, to 49see if any of them are already installed (of course, if you are not using 50.Xr ssh-agent 1 51this may result in you being repeatedly prompted for pass-phrases). 52It then assembles a list of those that failed to log in, and using ssh, 53enables logins with those keys on the remote server. By default it adds 54the keys by appending them to the remote user's 55.Pa ~/.ssh/authorized_keys 56(creating the file, and directory, if necessary). It is also capable 57of detecting if the remote system is a NetScreen, and using its 58.Ql set ssh pka-dsa key ... 59command instead. 60.Pp 61The options are as follows: 62.Bl -tag -width Ds 63.It Fl i Ar identity_file 64Use only the key(s) contained in 65.Ar identity_file 66(rather than looking for identities via 67.Xr ssh-add 1 68or in the 69.Ic default_ID_file ) . 70If the filename does not end in 71.Pa .pub 72this is added. If the filename is omitted, the 73.Ic default_ID_file 74is used. 75.Pp 76Note that this can be used to ensure that the keys copied have the 77comment one prefers and/or extra options applied, by ensuring that the 78key file has these set as preferred before the copy is attempted. 79.It Fl n 80do a dry-run. Instead of installing keys on the remote system simply 81prints the key(s) that would have been installed. 82.It Fl h , Fl ? 83Print Usage summary 84.It Fl p Ar port , Fl o Ar ssh_option 85These two options are simply passed through untouched, along with their 86argument, to allow one to set the port or other 87.Xr ssh 1 88options, respectively. 89.Pp 90Rather than specifying these as command line options, it is often better to use (per-host) settings in 91.Xr ssh 1 Ns 's 92configuration file: 93.Xr ssh_config 5 . 94.El 95.Pp 96Default behaviour without 97.Fl i , 98is to check if 99.Ql ssh-add -L 100provides any output, and if so those keys are used. Note that this results in 101the comment on the key being the filename that was given to 102.Xr ssh-add 1 103when the key was loaded into your 104.Xr ssh-agent 1 105rather than the comment contained in that file, which is a bit of a shame. 106Otherwise, if 107.Xr ssh-add 1 108provides no keys contents of the 109.Ic default_ID_file 110will be used. 111.Pp 112The 113.Ic default_ID_file 114is the most recent file that matches: 115.Pa ~/.ssh/id*.pub , 116(excluding those that match 117.Pa ~/.ssh/*-cert.pub ) 118so if you create a key that is not the one you want 119.Nm 120to use, just use 121.Xr touch 1 122on your preferred key's 123.Pa .pub 124file to reinstate it as the most recent. 125.Pp 126.Sh EXAMPLES 127If you have already installed keys from one system on a lot of remote 128hosts, and you then create a new key, on a new client machine, say, 129it can be difficult to keep track of which systems on which you've 130installed the new key. One way of dealing with this is to load both 131the new key and old key(s) into your 132.Xr ssh-agent 1 . 133Load the new key first, without the 134.Fl c 135option, then load one or more old keys into the agent, possibly by 136ssh-ing to the client machine that has that old key, using the 137.Fl A 138option to allow agent forwarding: 139.Pp 140.D1 user@newclient$ ssh-add 141.D1 user@newclient$ ssh -A old.client 142.D1 user@oldl$ ssh-add -c 143.D1 No ... prompt for pass-phrase ... 144.D1 user@old$ logoff 145.D1 user@newclient$ ssh someserver 146.Pp 147now, if the new key is installed on the server, you'll be allowed in 148unprompted, whereas if you only have the old key(s) enabled, you'll be 149asked for confirmation, which is your cue to log back out and run 150.Pp 151.D1 user@newclient$ ssh-copy-id -i someserver 152.Pp 153The reason you might want to specify the -i option in this case is to 154ensure that the comment on the installed key is the one from the 155.Pa .pub 156file, rather than just the filename that was loaded into you agent. 157It also ensures that only the id you intended is installed, rather than 158all the keys that you have in your 159.Xr ssh-agent 1 . 160Of course, you can specify another id, or use the contents of the 161.Xr ssh-agent 1 162as you prefer. 163.Pp 164Having mentioned 165.Xr ssh-add 1 Ns 's 166.Fl c 167option, you might consider using this whenever using agent forwarding 168to avoid your key being hijacked, but it is much better to instead use 169.Xr ssh 1 Ns 's 170.Ar ProxyCommand 171and 172.Fl W 173option, 174to bounce through remote servers while always doing direct end-to-end 175authentication. This way the middle hop(s) don't get access to your 176.Xr ssh-agent 1 . 177A web search for 178.Ql ssh proxycommand nc 179should prove enlightening (N.B. the modern approach is to use the 180.Fl W 181option, rather than 182.Xr nc 1 ) . 183.Sh "SEE ALSO" 184.Xr ssh 1 , 185.Xr ssh-agent 1 , 186.Xr sshd 8
|