I have some experience using the bash, but this command here which I saw in a tutorial caught me off guard:
cat ~/.ssh/id_rsa.pub | ssh git@remote-server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
I know what the command does. It takes the output of the file
sshs to a remote server, creates a new directory under user home called .ssh then creates a new file called
authorized_keys and pours the contents of the
id_rsa.pub into that file. What I couldn't figure out is, at which point contents of the
id_rsa.pub file gets injected into the authorized keys file.
So, I know pipe (|) takes the output to its left and feeds it to the command to the right hand side of it. But normally we use cat command like this:
cat "content_to_be_added" >> file_to_be_appended
so, if I'm not mistaken, contents of
id_rsa.pub should get injected right before >> in order for this to work. So, how does this function exactly and why?
By the way, please feel free to correct my terminology. I'd also appreciate if you can tell me if this operator here
>> has a specific name.