Hint: ssh-copy-id and different ssh port

ssh-copy-id is a dedicated tool to set up public key authentication via ssh between two linux machines. You will get a problem, if the ssh daemon is listening on a different port (for example: 2222). The standard ssh-copy-id command in Ubuntu Linux doesn’t support a custom SSH port. According to the man page there are only a few parameters available:

NAME
ssh-copy-id - install your public key in a remote machine's autho-
rized_keys

SYNOPSIS
ssh-copy-id [-i [identity_file]] [user@]machine

There is a trick, that does the deal: ssh-copy-id passes on custom parameters directly to ssh by quoting the custom string:
ssh-copy-id -i /path/to/id_foobar.pub "-p 2222 user@server"

You can see, that it is possible to use all known params from ssh to ssh-copy-id, especially needed for custom ssh ports like in this case.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>