Is it possible to run ssh-copy-id on port other than 22?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












94














I have a server with SSH running on a non-standard port. Instead of 22, it runs on 8129. To log in, I use:



ssh -p 8129 hostname


Now, whenever I need to set up a key for password-less login, I have to copy the public key and add it to authorized_keys manually. I discovered that the command ssh-copy-id could be used to simplify this process, but it seems like it does not have an option to specify the port of the ssh server.



Is there some way to tell ssh-copy-id to use port 8129, or should I just forget about this command and copy/paste manually as before?










share|improve this question




























    94














    I have a server with SSH running on a non-standard port. Instead of 22, it runs on 8129. To log in, I use:



    ssh -p 8129 hostname


    Now, whenever I need to set up a key for password-less login, I have to copy the public key and add it to authorized_keys manually. I discovered that the command ssh-copy-id could be used to simplify this process, but it seems like it does not have an option to specify the port of the ssh server.



    Is there some way to tell ssh-copy-id to use port 8129, or should I just forget about this command and copy/paste manually as before?










    share|improve this question


























      94












      94








      94


      26





      I have a server with SSH running on a non-standard port. Instead of 22, it runs on 8129. To log in, I use:



      ssh -p 8129 hostname


      Now, whenever I need to set up a key for password-less login, I have to copy the public key and add it to authorized_keys manually. I discovered that the command ssh-copy-id could be used to simplify this process, but it seems like it does not have an option to specify the port of the ssh server.



      Is there some way to tell ssh-copy-id to use port 8129, or should I just forget about this command and copy/paste manually as before?










      share|improve this question















      I have a server with SSH running on a non-standard port. Instead of 22, it runs on 8129. To log in, I use:



      ssh -p 8129 hostname


      Now, whenever I need to set up a key for password-less login, I have to copy the public key and add it to authorized_keys manually. I discovered that the command ssh-copy-id could be used to simplify this process, but it seems like it does not have an option to specify the port of the ssh server.



      Is there some way to tell ssh-copy-id to use port 8129, or should I just forget about this command and copy/paste manually as before?







      ssh






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 '12 at 0:16









      Kevin

      26.9k106199




      26.9k106199










      asked Jan 18 '12 at 23:29









      Milan Babuškov

      93721012




      93721012




















          9 Answers
          9






          active

          oldest

          votes


















          106














          $ ssh-copy-id "-p 8129 user@host"


          Source: http://it-ride.blogspot.com/2009/11/use-ssh-copy-id-on-different-port.html



          NOTE: The port must be in front of the user@host or it will not resolve






          share|improve this answer


















          • 8




            It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
            – Tombart
            Feb 4 '15 at 12:58






          • 2




            @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
            – garetmckinley
            Sep 25 '15 at 4:10






          • 1




            @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
            – meshy
            Jan 8 '16 at 11:46










          • FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
            – degenerate
            Dec 2 '17 at 2:40










          • On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
            – Arjun Mehta
            May 21 at 15:57


















          45














          ssh-copy-id doesn't take any arguments that it could pass down to the underlying ssh command, but you can configure an alias in ~/.ssh/config.



          Host myhost
          HostName hostname
          Port 8129


          Then run ssh-copy-id myhost.






          share|improve this answer
















          • 3




            This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
            – Warren Young
            Jan 20 '12 at 14:00











          • Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
            – Lonniebiz
            Aug 9 '16 at 15:53


















          14














          As of openssh-client_6.2 there is now a dedicated port flag for the command allowing for this syntax:



          ssh-copy-id -p 8129 user@example


          It also added support for adding other ssh options with the -o flag.



          Here's is Ubuntu's man page for the appropriate version, introduced in 13.04: http://manpages.ubuntu.com/manpages/saucy/man1/ssh-copy-id.1.html






          share|improve this answer


















          • 2




            This is the only method which worked for the.
            – Luca Steeb
            Aug 23 '16 at 22:13


















          11














          A quick look at the source indicates that ssh-copy-id appears to have no function that permits this. However, you could do something like the following instead:



          ssh -p8129 user@host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_*.pub





          share|improve this answer




























            6














            This works (from here):



            ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 221 username@host'





            share|improve this answer






























              5














              I have always used scp to copy it over:



              scp -P 8129 ~/.ssh/id_*.pub user@host:
              ssh -p 8129 user@host 'cat id_*.pub >> ~/.ssh/authorized_keys'


              Though I must say, I'll probably be using the other (one-line/connection) methods if I remember them in the future. But this is another option for you.






              share|improve this answer




























                2














                On CentOS7 is just:



                 ssh-copy-id "-p 1234" user@host


                Please take care to don't place user@host within the quotes or you'll get the following error in this distribution:



                /usr/bin/ssh-copy-id: ERROR: Bad port ' 1234 user@host'





                share|improve this answer




























                  0














                  With my macOS, this worked.



                  ssh-copy-id -i ~/.ssh/id_rsa.pub -p <port> user@host





                  share|improve this answer




























                    0














                    I use this command:



                    ssh-copy-id ssh://user@ip_addr:port



                    Example:



                    ssh-copy-id ssh://root@1.2.3.4:23






                    share|improve this answer




















                      Your Answer








                      StackExchange.ready(function()
                      var channelOptions =
                      tags: "".split(" "),
                      id: "106"
                      ;
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function()
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled)
                      StackExchange.using("snippets", function()
                      createEditor();
                      );

                      else
                      createEditor();

                      );

                      function createEditor()
                      StackExchange.prepareEditor(
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: false,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: null,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader:
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      ,
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      );



                      );













                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f29401%2fis-it-possible-to-run-ssh-copy-id-on-port-other-than-22%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown

























                      9 Answers
                      9






                      active

                      oldest

                      votes








                      9 Answers
                      9






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      106














                      $ ssh-copy-id "-p 8129 user@host"


                      Source: http://it-ride.blogspot.com/2009/11/use-ssh-copy-id-on-different-port.html



                      NOTE: The port must be in front of the user@host or it will not resolve






                      share|improve this answer


















                      • 8




                        It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
                        – Tombart
                        Feb 4 '15 at 12:58






                      • 2




                        @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
                        – garetmckinley
                        Sep 25 '15 at 4:10






                      • 1




                        @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
                        – meshy
                        Jan 8 '16 at 11:46










                      • FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
                        – degenerate
                        Dec 2 '17 at 2:40










                      • On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
                        – Arjun Mehta
                        May 21 at 15:57















                      106














                      $ ssh-copy-id "-p 8129 user@host"


                      Source: http://it-ride.blogspot.com/2009/11/use-ssh-copy-id-on-different-port.html



                      NOTE: The port must be in front of the user@host or it will not resolve






                      share|improve this answer


















                      • 8




                        It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
                        – Tombart
                        Feb 4 '15 at 12:58






                      • 2




                        @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
                        – garetmckinley
                        Sep 25 '15 at 4:10






                      • 1




                        @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
                        – meshy
                        Jan 8 '16 at 11:46










                      • FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
                        – degenerate
                        Dec 2 '17 at 2:40










                      • On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
                        – Arjun Mehta
                        May 21 at 15:57













                      106












                      106








                      106






                      $ ssh-copy-id "-p 8129 user@host"


                      Source: http://it-ride.blogspot.com/2009/11/use-ssh-copy-id-on-different-port.html



                      NOTE: The port must be in front of the user@host or it will not resolve






                      share|improve this answer














                      $ ssh-copy-id "-p 8129 user@host"


                      Source: http://it-ride.blogspot.com/2009/11/use-ssh-copy-id-on-different-port.html



                      NOTE: The port must be in front of the user@host or it will not resolve







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jul 24 at 1:57









                      slm

                      247k66507675




                      247k66507675










                      answered Feb 25 '13 at 17:37









                      Jsan

                      1,076182




                      1,076182







                      • 8




                        It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
                        – Tombart
                        Feb 4 '15 at 12:58






                      • 2




                        @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
                        – garetmckinley
                        Sep 25 '15 at 4:10






                      • 1




                        @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
                        – meshy
                        Jan 8 '16 at 11:46










                      • FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
                        – degenerate
                        Dec 2 '17 at 2:40










                      • On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
                        – Arjun Mehta
                        May 21 at 15:57












                      • 8




                        It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
                        – Tombart
                        Feb 4 '15 at 12:58






                      • 2




                        @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
                        – garetmckinley
                        Sep 25 '15 at 4:10






                      • 1




                        @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
                        – meshy
                        Jan 8 '16 at 11:46










                      • FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
                        – degenerate
                        Dec 2 '17 at 2:40










                      • On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
                        – Arjun Mehta
                        May 21 at 15:57







                      8




                      8




                      It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
                      – Tombart
                      Feb 4 '15 at 12:58




                      It's really stupid, that ssh has syntax ssh -p 1234 user@host, ssh-copy-id "-p 1234 user@host" and finally scp -P 1234 user@host. It would be so nice to have the same syntax.
                      – Tombart
                      Feb 4 '15 at 12:58




                      2




                      2




                      @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
                      – garetmckinley
                      Sep 25 '15 at 4:10




                      @Tombart and then rsync has rsync -e "ssh -p 1234" user@host. I swear it's more hassle than it's worth using a custom port.
                      – garetmckinley
                      Sep 25 '15 at 4:10




                      1




                      1




                      @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
                      – meshy
                      Jan 8 '16 at 11:46




                      @Colt McCormack's answer explains this is improved in new versions, and this peculiar syntax is no longer required.
                      – meshy
                      Jan 8 '16 at 11:46












                      FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
                      – degenerate
                      Dec 2 '17 at 2:40




                      FYI the full command requires the IP typed in twice, and should look something like: ssh-copy-id "root@192.168.0.100 -p 12345" -i ~/.ssh/id_rsa.pub 192.168.0.100
                      – degenerate
                      Dec 2 '17 at 2:40












                      On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
                      – Arjun Mehta
                      May 21 at 15:57




                      On macOS (I am on High Sierra) the quotes are not required. ie. ssh-copy-id -p 8129 user@host works.
                      – Arjun Mehta
                      May 21 at 15:57













                      45














                      ssh-copy-id doesn't take any arguments that it could pass down to the underlying ssh command, but you can configure an alias in ~/.ssh/config.



                      Host myhost
                      HostName hostname
                      Port 8129


                      Then run ssh-copy-id myhost.






                      share|improve this answer
















                      • 3




                        This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
                        – Warren Young
                        Jan 20 '12 at 14:00











                      • Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
                        – Lonniebiz
                        Aug 9 '16 at 15:53















                      45














                      ssh-copy-id doesn't take any arguments that it could pass down to the underlying ssh command, but you can configure an alias in ~/.ssh/config.



                      Host myhost
                      HostName hostname
                      Port 8129


                      Then run ssh-copy-id myhost.






                      share|improve this answer
















                      • 3




                        This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
                        – Warren Young
                        Jan 20 '12 at 14:00











                      • Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
                        – Lonniebiz
                        Aug 9 '16 at 15:53













                      45












                      45








                      45






                      ssh-copy-id doesn't take any arguments that it could pass down to the underlying ssh command, but you can configure an alias in ~/.ssh/config.



                      Host myhost
                      HostName hostname
                      Port 8129


                      Then run ssh-copy-id myhost.






                      share|improve this answer












                      ssh-copy-id doesn't take any arguments that it could pass down to the underlying ssh command, but you can configure an alias in ~/.ssh/config.



                      Host myhost
                      HostName hostname
                      Port 8129


                      Then run ssh-copy-id myhost.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 19 '12 at 0:11









                      Gilles

                      527k12710561581




                      527k12710561581







                      • 3




                        This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
                        – Warren Young
                        Jan 20 '12 at 14:00











                      • Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
                        – Lonniebiz
                        Aug 9 '16 at 15:53












                      • 3




                        This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
                        – Warren Young
                        Jan 20 '12 at 14:00











                      • Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
                        – Lonniebiz
                        Aug 9 '16 at 15:53







                      3




                      3




                      This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
                      – Warren Young
                      Jan 20 '12 at 14:00





                      This also has the benefit of removing the need for the -p flag on regular ssh attempts. It is therefore not only the right answer to this question, it is The Right Thing, period.
                      – Warren Young
                      Jan 20 '12 at 14:00













                      Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
                      – Lonniebiz
                      Aug 9 '16 at 15:53




                      Thanks for this. The 2nd line "HostName hostname" isn't necessary if you are satisfied with the host's natural hostname.
                      – Lonniebiz
                      Aug 9 '16 at 15:53











                      14














                      As of openssh-client_6.2 there is now a dedicated port flag for the command allowing for this syntax:



                      ssh-copy-id -p 8129 user@example


                      It also added support for adding other ssh options with the -o flag.



                      Here's is Ubuntu's man page for the appropriate version, introduced in 13.04: http://manpages.ubuntu.com/manpages/saucy/man1/ssh-copy-id.1.html






                      share|improve this answer


















                      • 2




                        This is the only method which worked for the.
                        – Luca Steeb
                        Aug 23 '16 at 22:13















                      14














                      As of openssh-client_6.2 there is now a dedicated port flag for the command allowing for this syntax:



                      ssh-copy-id -p 8129 user@example


                      It also added support for adding other ssh options with the -o flag.



                      Here's is Ubuntu's man page for the appropriate version, introduced in 13.04: http://manpages.ubuntu.com/manpages/saucy/man1/ssh-copy-id.1.html






                      share|improve this answer


















                      • 2




                        This is the only method which worked for the.
                        – Luca Steeb
                        Aug 23 '16 at 22:13













                      14












                      14








                      14






                      As of openssh-client_6.2 there is now a dedicated port flag for the command allowing for this syntax:



                      ssh-copy-id -p 8129 user@example


                      It also added support for adding other ssh options with the -o flag.



                      Here's is Ubuntu's man page for the appropriate version, introduced in 13.04: http://manpages.ubuntu.com/manpages/saucy/man1/ssh-copy-id.1.html






                      share|improve this answer














                      As of openssh-client_6.2 there is now a dedicated port flag for the command allowing for this syntax:



                      ssh-copy-id -p 8129 user@example


                      It also added support for adding other ssh options with the -o flag.



                      Here's is Ubuntu's man page for the appropriate version, introduced in 13.04: http://manpages.ubuntu.com/manpages/saucy/man1/ssh-copy-id.1.html







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Sep 8 '14 at 21:12

























                      answered Sep 8 '14 at 15:48









                      Colt McCormack

                      24124




                      24124







                      • 2




                        This is the only method which worked for the.
                        – Luca Steeb
                        Aug 23 '16 at 22:13












                      • 2




                        This is the only method which worked for the.
                        – Luca Steeb
                        Aug 23 '16 at 22:13







                      2




                      2




                      This is the only method which worked for the.
                      – Luca Steeb
                      Aug 23 '16 at 22:13




                      This is the only method which worked for the.
                      – Luca Steeb
                      Aug 23 '16 at 22:13











                      11














                      A quick look at the source indicates that ssh-copy-id appears to have no function that permits this. However, you could do something like the following instead:



                      ssh -p8129 user@host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_*.pub





                      share|improve this answer

























                        11














                        A quick look at the source indicates that ssh-copy-id appears to have no function that permits this. However, you could do something like the following instead:



                        ssh -p8129 user@host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_*.pub





                        share|improve this answer























                          11












                          11








                          11






                          A quick look at the source indicates that ssh-copy-id appears to have no function that permits this. However, you could do something like the following instead:



                          ssh -p8129 user@host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_*.pub





                          share|improve this answer












                          A quick look at the source indicates that ssh-copy-id appears to have no function that permits this. However, you could do something like the following instead:



                          ssh -p8129 user@host 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_*.pub






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 18 '12 at 23:37









                          Chris Down

                          79k14188202




                          79k14188202





















                              6














                              This works (from here):



                              ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 221 username@host'





                              share|improve this answer



























                                6














                                This works (from here):



                                ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 221 username@host'





                                share|improve this answer

























                                  6












                                  6








                                  6






                                  This works (from here):



                                  ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 221 username@host'





                                  share|improve this answer














                                  This works (from here):



                                  ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 221 username@host'






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Dec 14 at 20:23









                                  Jeff Schaller

                                  38.5k1053125




                                  38.5k1053125










                                  answered Sep 2 '12 at 6:25









                                  DJR

                                  6111




                                  6111





















                                      5














                                      I have always used scp to copy it over:



                                      scp -P 8129 ~/.ssh/id_*.pub user@host:
                                      ssh -p 8129 user@host 'cat id_*.pub >> ~/.ssh/authorized_keys'


                                      Though I must say, I'll probably be using the other (one-line/connection) methods if I remember them in the future. But this is another option for you.






                                      share|improve this answer

























                                        5














                                        I have always used scp to copy it over:



                                        scp -P 8129 ~/.ssh/id_*.pub user@host:
                                        ssh -p 8129 user@host 'cat id_*.pub >> ~/.ssh/authorized_keys'


                                        Though I must say, I'll probably be using the other (one-line/connection) methods if I remember them in the future. But this is another option for you.






                                        share|improve this answer























                                          5












                                          5








                                          5






                                          I have always used scp to copy it over:



                                          scp -P 8129 ~/.ssh/id_*.pub user@host:
                                          ssh -p 8129 user@host 'cat id_*.pub >> ~/.ssh/authorized_keys'


                                          Though I must say, I'll probably be using the other (one-line/connection) methods if I remember them in the future. But this is another option for you.






                                          share|improve this answer












                                          I have always used scp to copy it over:



                                          scp -P 8129 ~/.ssh/id_*.pub user@host:
                                          ssh -p 8129 user@host 'cat id_*.pub >> ~/.ssh/authorized_keys'


                                          Though I must say, I'll probably be using the other (one-line/connection) methods if I remember them in the future. But this is another option for you.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Jan 19 '12 at 0:21









                                          Kevin

                                          26.9k106199




                                          26.9k106199





















                                              2














                                              On CentOS7 is just:



                                               ssh-copy-id "-p 1234" user@host


                                              Please take care to don't place user@host within the quotes or you'll get the following error in this distribution:



                                              /usr/bin/ssh-copy-id: ERROR: Bad port ' 1234 user@host'





                                              share|improve this answer

























                                                2














                                                On CentOS7 is just:



                                                 ssh-copy-id "-p 1234" user@host


                                                Please take care to don't place user@host within the quotes or you'll get the following error in this distribution:



                                                /usr/bin/ssh-copy-id: ERROR: Bad port ' 1234 user@host'





                                                share|improve this answer























                                                  2












                                                  2








                                                  2






                                                  On CentOS7 is just:



                                                   ssh-copy-id "-p 1234" user@host


                                                  Please take care to don't place user@host within the quotes or you'll get the following error in this distribution:



                                                  /usr/bin/ssh-copy-id: ERROR: Bad port ' 1234 user@host'





                                                  share|improve this answer












                                                  On CentOS7 is just:



                                                   ssh-copy-id "-p 1234" user@host


                                                  Please take care to don't place user@host within the quotes or you'll get the following error in this distribution:



                                                  /usr/bin/ssh-copy-id: ERROR: Bad port ' 1234 user@host'






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Feb 25 at 12:35









                                                  Max Cuttins

                                                  213




                                                  213





















                                                      0














                                                      With my macOS, this worked.



                                                      ssh-copy-id -i ~/.ssh/id_rsa.pub -p <port> user@host





                                                      share|improve this answer

























                                                        0














                                                        With my macOS, this worked.



                                                        ssh-copy-id -i ~/.ssh/id_rsa.pub -p <port> user@host





                                                        share|improve this answer























                                                          0












                                                          0








                                                          0






                                                          With my macOS, this worked.



                                                          ssh-copy-id -i ~/.ssh/id_rsa.pub -p <port> user@host





                                                          share|improve this answer












                                                          With my macOS, this worked.



                                                          ssh-copy-id -i ~/.ssh/id_rsa.pub -p <port> user@host






                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Nov 30 '16 at 7:16









                                                          Jin Kwon

                                                          226112




                                                          226112





















                                                              0














                                                              I use this command:



                                                              ssh-copy-id ssh://user@ip_addr:port



                                                              Example:



                                                              ssh-copy-id ssh://root@1.2.3.4:23






                                                              share|improve this answer

























                                                                0














                                                                I use this command:



                                                                ssh-copy-id ssh://user@ip_addr:port



                                                                Example:



                                                                ssh-copy-id ssh://root@1.2.3.4:23






                                                                share|improve this answer























                                                                  0












                                                                  0








                                                                  0






                                                                  I use this command:



                                                                  ssh-copy-id ssh://user@ip_addr:port



                                                                  Example:



                                                                  ssh-copy-id ssh://root@1.2.3.4:23






                                                                  share|improve this answer












                                                                  I use this command:



                                                                  ssh-copy-id ssh://user@ip_addr:port



                                                                  Example:



                                                                  ssh-copy-id ssh://root@1.2.3.4:23







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered Dec 14 at 20:03









                                                                  Carlos

                                                                  11




                                                                  11



























                                                                      draft saved

                                                                      draft discarded
















































                                                                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                      But avoid


                                                                      • Asking for help, clarification, or responding to other answers.

                                                                      • Making statements based on opinion; back them up with references or personal experience.

                                                                      To learn more, see our tips on writing great answers.





                                                                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                      Please pay close attention to the following guidance:


                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                      But avoid


                                                                      • Asking for help, clarification, or responding to other answers.

                                                                      • Making statements based on opinion; back them up with references or personal experience.

                                                                      To learn more, see our tips on writing great answers.




                                                                      draft saved


                                                                      draft discarded














                                                                      StackExchange.ready(
                                                                      function ()
                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f29401%2fis-it-possible-to-run-ssh-copy-id-on-port-other-than-22%23new-answer', 'question_page');

                                                                      );

                                                                      Post as a guest















                                                                      Required, but never shown





















































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown

































                                                                      Required, but never shown














                                                                      Required, but never shown












                                                                      Required, but never shown







                                                                      Required, but never shown






                                                                      Popular posts from this blog

                                                                      How to check contact read email or not when send email to Individual?

                                                                      Bahrain

                                                                      Postfix configuration issue with fips on centos 7; mailgun relay