How can I make ssh-copy-id use a port other than 22?

I tried it with -p but I get:

ssh-copy-id -p XXX XXXX@XX.XX.XX.XX
Bad port 'umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys'

I know that the port is good because I'm connected to the server on that port.


Set the port to use in ~/.ssh/config like the following:

Host secret-host.example.com
Port 2222

I use this command, note the quotes:

ssh-copy-id -i ~/.ssh/id_dsa.pub "user@host -p 6842"

Try this:

ssh-copy-id "user@host -p 8888"
ssh-copy-id -i ~/.ssh/id_rsa.pub ‘-p 221 username@host’

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.