Skip to content

Instantly share code, notes, and snippets.

@thinkjrs
Forked from nickbayley/alt-ssh-copy-id.md
Created October 15, 2022 20:25
Show Gist options
  • Save thinkjrs/0792872fb8af3b320f0cd2a66079a024 to your computer and use it in GitHub Desktop.
Save thinkjrs/0792872fb8af3b320f0cd2a66079a024 to your computer and use it in GitHub Desktop.
Simple Alternative to ssh-copy-id

Simple Alternative to ssh-copy-id

Replace user with the name of the user you want to ssh as.

Replace the ip with the ip of the machine / host / vps you want to connect to.

cat ~/.ssh/id_rsa.pub | ssh user@ip "cat >> ~/.ssh/authorized_keys"

If the directory .ssh is not yet created on the machine / host / vps, use this small variation:

cat ~/.ssh/id_rsa.pub | ssh user@ip "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment