-
-
Save elonmallin/2cc94c45ab57e2060498e855acefade0 to your computer and use it in GitHub Desktop.
ssh-keygen && cat $env:userprofile/.ssh/id_rsa.pub | ssh user@linuxserver 'cat >> .ssh/authorized_keys' |
There is a typo!?
Before the pipe( |
) , $env
and userprofile
must have :
in between.
Also all the /
is replaced by \
, before the piping into linux server.
ssh-keygen && cat $env:userprofile\.ssh\id_rsa.pub | ssh user@linuxserver 'cat >> .ssh/authorized_keys'
I Recommend :
ssh-keygen -o -a 100 -t ed25519 -f id_ed25519.pub -C "user@windowsclient" && cat $env:USERPROFILE\.ssh\id_ed25519.pub | ssh user@linuxserver "mkdir ~/.ssh/ ; touch ~/.ssh/authorized_keys ; cat >> ~/.ssh/authorized_keys"
Goodluck
There is a typo!?
Before the pipe(
|
) ,$env
anduserprofile
must have:
in between. Also all the/
is replaced by\
, before the piping into linux server.ssh-keygen && cat $env:userprofile\.ssh\id_rsa.pub | ssh user@linuxserver 'cat >> .ssh/authorized_keys'
I Recommend :
ssh-keygen -o -a 100 -t ed25519 -f id_ed25519.pub -C "user@windowsclient" && cat $env:USERPROFILE\.ssh\id_ed25519.pub | ssh user@linuxserver "mkdir ~/.ssh/ ; touch ~/.ssh/authorized_keys ; cat >> ~/.ssh/authorized_keys"
Goodluck
Thanks, I added the :
to the env var. Don't know what you mean by the slashes since what is being piped to the ssh command is the content so slashes should have no impact. I'll keep the command shorter and ppl can feel free to add more specific params if they want =)
Don't know what you mean by the slashes since what is being piped to the ssh command is the content so slashes should have no impact.
usually windows have '\' and linux and unix have '/' so i was concerned. It seems, when used with $env:USERPROFILE
, either / or \ is fine.
i also followed chris's article on https://chrisjhart.com/Windows-10-ssh-copy-id/#copy-ssh-key-to-remote-linux-device
Thanks!