Skip to content
Afa' Afa'

Copy SSH Key to a Server

Install an SSH public key on a remote server by hand when ssh-copy-id is unavailable.

1 min read Updated

ssh-copy-id is the easy way to install a public key on a remote host, but it is not always available. This snippet does the same thing by hand: create ~/.ssh, tighten its permissions and append the key to authorized_keys. The commands are below.

SSH.com explains how to copy a SSH key to a remote server with ssh-copy-id. This explains how to do that manually with a command line.

copy-ssh-key.sh

bash
mkdir -p ~/.ssh
chmod 700 ~/.ssh
vim ~/.ssh/authorized_keys # paste your SSH key ~/.ssh/id_rsa.pub
Something wrong or want to discuss this article? Get in touch

Search articles and projects

Type to filter articles and projects. Use the arrow keys to move through results and Enter to open one. Press Escape to close.