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"
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"