Ubuntu – How to make ssh-copy-id use a port other than 22

bashssh

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.

Best Answer

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

Host secret-host.example.com
Port 2222
Related Question