Copy public key to FreeBSD error

Hello, I'm trying to copy a public key to FreeBSB and I always use the same command, however FreeBSD syntax is a little different to what I'm used to.
My command is:
Bash:
linuxmint@linuxmint:~$ cat ~/.ssh/id_rsa.pub | ssh admin@192.168.1.170 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Password for admin@pfSense.localdomain:

However I receive the error:
Bash:
usage: mkdir [-pv] [-m mode] directory_name ...
 
why don't you just use "ssh-copy-id"? It does exactly what you are trying to do and works over several platforms (I'm using it e.g. between FreeBSD, OpenBSD and smartos/illumos hosts)

As for your command, I suspect you are feeding the output of 'cat' to 'mkdir' which will not work. Maybe bash is doing something different here and ignores stdin for mkdir. Never use bashisms if you intend do be compatible - bash is almost never a standard shell except in the linux ecosystem!
 
Thank you for the informative reply.
I've used that command before ssh-copy-id was created. Always worked for me up until today.
I'll try ssh-copy-id.
May I ask what language to use, as I appreciate your bashism comment?
 
Sweet! That worked. I had to name my key as per the previously generated key id_rsa.pub. Didn't feel like changing my public key and copying to all the clients.
Thank you for the informative reply.
I've used that command before ssh-copy-id was created. Always worked for me up until today.
I'll try ssh-copy-id.
May I ask what language to use, as I appreciate your bashism comment?
 
Back
Top