GNU/Linux Inside

ssh-copy-id and sshd port

For security purposes, I don’t run sshd on the default port (22). This gave me some problems when attempting to use the command ssh-copy-id. Ideally, you’d expect the following to work:

1
ssh-copy-id -p XXXX -i ~/.ssh/id_rsa.pub username@host

However, that didn’t do anything but output an error:

Bad port 'umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys'

The solution was to enclose it in quotes as follows:

ssh-copy-id ‘-p XXXX -i ~/.ssh/id_rsa.pub username@host’

Hope that helps.

(The above error probably doesn’t make any sense. ssh-copy-id is a shell script. The command that appears in the error message is a command sent to the server via SSH. Feel free to take a look at the file: cat `locate ssh-copy-id | head -n1`)

No Trackbacks

You can leave a trackback using this URL: http://mikegerwitz.com/2009/10/07/ssh-copy-id-and-sshd-port/trackback/

One Comment

  1. ssh-copy-id -i ~/.ssh/id_rsa.pub ‘-p xxxx username@host’
    also works and is more intuitive :)

    Posted July 18, 2010 at 9:05 am | Permalink

Post a Comment

Your email is never shared. Required fields are marked *

*
*