Written on 01. Jan 2012, 18:09
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:
ssh-copy-id - install your public key in a remote machine's autho-
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.
What is the content of this blog, you may ask? My name is Julian Joswig and I am a big fan of IT and technology (mainly Linux, servers, networks and all related topics). Sometimes I almost bite my teeth on difficult issues. But if I have found a solution, I want to share it with the world. Professionally, I work as a management consultant in Germany with a focus on IT and business.