Skip to content

Instantly share code, notes, and snippets.

@nickbayley
Last active September 5, 2024 12:09
Show Gist options
  • Save nickbayley/ef2b6744b976c96db6e9 to your computer and use it in GitHub Desktop.
Save nickbayley/ef2b6744b976c96db6e9 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"
@butaford
Copy link

windows 10/11 cmd:
type C:\Users\<USER>/.ssh/id_rsa.pub | ssh user@ip "cat >> ~/.ssh/authorized_keys"
type C:\Users\<USER>/.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