hello,
i like cmder,much better than putty.great work.
i would want to know how to add ssh-copy-id on cmder.
i have try some script that i found on internet but that don't working.
is there a solution to get ssh-copy-id?
thank you very much.
I know it's not perfect, but this is the alias I have been using to fill the gap a little:
ssh-copy-id=cat ~/.ssh/id_rsa.pub | ssh $1 "[ ! -d ~/.ssh ] && mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
And here is the command:
ssh-copy-id [user@]machine
I use id_rsa.pub, but you could add a second argument for the alias if you needed to specify that too.
This command will attempt to SSH into the provided machine ($1), and execute commands that will create the .ssh folder if necessary, and then append the contents of id_rsa.pub into the authorized_keys file.
Note: This will not check to see if the key is already trusted, so it is possible to get multiple entries in the authorized_keys file.
Its good enough for my needs right now, but if it isn't for yours I may have ideas on how to improve it, so let me know.
If you wanted to remove duplicates, here's an example of a way to do that from the remote machine:
sort -u ~/.ssh/authorized_keys -o ~/.ssh/authorized_keys
You could also add this to the ssh-copy-id alias. Then every time you run ssh-copy-id it will remove duplicates on the remote machine. like this:
ssh-copy-id=cat ~/.ssh/id_rsa.pub | ssh $1 "[ ! -d ~/.ssh ] && mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys && sort -u ~/.ssh/authorized_keys -o ~/.ssh/authorized_keys"
I have added the command above to the aliases file but it doens't work.
Every time i try it, only the cat command is executed but not the pipe.
Any idea why??
Thx in advance
Still don't know why it didn't work but now its working.
Only thing is that the permissions are not correct when making the .ssh folder.
I changed the command to this:
ssh-copy-id=cat ~/.ssh/id_rsa.pub | ssh $1 "[ ! -d ~/.ssh ] && mkdir ~/.ssh && chmod 700 ~/.ssh; cat >> ~/.ssh/authorized_keys && sort -u ~/.ssh/authorized_keys -o ~/.ssh/authorized_keys && chmod 700 ~/.ssh/authorized_keys"
Good catch on the permissions. Its been a while since I worked on that alias, and I think all of my machines I had been interacting with already had the directory, but I remember I threw in the mkdir just in case. Very good to have the permissions setup correctly though.
Asked and answered.
Most helpful comment
Still don't know why it didn't work but now its working.
Only thing is that the permissions are not correct when making the .ssh folder.
I changed the command to this:
ssh-copy-id=cat ~/.ssh/id_rsa.pub | ssh $1 "[ ! -d ~/.ssh ] && mkdir ~/.ssh && chmod 700 ~/.ssh; cat >> ~/.ssh/authorized_keys && sort -u ~/.ssh/authorized_keys -o ~/.ssh/authorized_keys && chmod 700 ~/.ssh/authorized_keys"