I want to execute the following command from a script.
public_ley contains a public key that starts with ssh-rsa AAAAB3NzaC1yc2, but when the ssh I execute the command does not pass all the content of the variable, as if I made a trim and only contains ssh-rsa and trim the rest, Who knows how to make the whole string happen to him?
publickey is a local file that contains the public key, it should be clarified that if I run it locally, it works, I mean, echo $ public_ley contains all the string, the problem is when I execute it by ssh.
public_key='cat publickey'
ssh $username@$p -i $key_path/$key_name "sudo bash /tmp/update-sshkey.sh $username $public_key"
the script update-sshkey.sh takes as parameters the user name and the key which I assign to two variables with $ 1 and $ 2, $ 2 contains only ssh-rsa and not the rest of the key
I also tried this:
command='ssh -t $username@$p -i /root/.ssh/$key_name "sudo bash /tmp/update-sshkey.sh $username $public_key"'
Thanks