0

Instead of typing in the content of a public key I want to pass the content of it as an input. The command used is

ipa user-mod user --sshpubkey='ssh-rsa AAA ........'

This work.

When I do

ipa user-mod user --sshpubkey=`cat ~/.ssh/id_rsa.pub`

or other combinations I get an error.

ipa: ERROR: command 'user_mod' takes at most 1 argument.

How can I convert the text file to a single argument after the equal sign?

Romeo Ninov
  • 17,484

1 Answers1

1

You will need to quote the command substitution to prevent the shell from splitting the output of the cat command into separate words on the characters in $IFS (space, tab, and newline by default) and to avoid having the shell perform filename globbing on each of those words.

In short,

ipa user-mod user --sshpubkey="`cat ~/.ssh/id_rsa.pub`"

Or, using the newer and friendlier $(...) syntax and getting rid of cat:

ipa user-mod user --sshpubkey="$(<~/.ssh/id_rsa.pub)"

See also:

Kusalananda
  • 333,661