I am trying one line setup command.
ssh -i "$(cat kushal.pub)" kushal@ec2-18-216-221-164.us-east-2.compute.amazonaws.com "mkdir -p ~/.ssh && chmod 700 && touch ~/.ssh/authorized_keys && chmod 600 cat >> ~/.ssh/authorized_keys"
Just to break this real quick I'm reading my .pub file and then while connecting, I am creating a .ssh folder with permissions 700 and inside that folder a file with permission 600 appending my public key into it.
But I get permission Denied error(public key).
Now, I did have connected instance manually by copying the public key generated by ssh-keygen -y
and through a series of commands. But I don't what's going wrong with the same commands but in one line. How can I work it out?
And to overflow my question a bit more. Is there any difference if I use ssh-keygen -y
compared to ssh-keygen - t rsa
for generating public key files?
Just making sure if this won't make any difference to the error output