Using ssh-copy-id on an alternative SSH destination port

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, February 28, 2012

Follow me on Twitter as @mattiasgeniar

By far the easiest way to copy SSH authorized public keys is using the ssh-copy-id tool, but it has a quirky syntax issue when you try to use it on a remote SSH server that’s operating on a non-standard port. If you want to use it, try the following.

# ssh-copy-id "mattias@host.be -p 1234"

Any other variation will most likely fail.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.