If I ssh to pfSense I have to select 8 to access the shell then I can run my commands as root.
If I create a new user I can ssh direct to the shell, but have no root access.
I'm trying to write a script that will log me in, select option 8 and then run my commands.
$rules="rules information is place in this var. 1n is used for new lines"
ssh admin@192.168.1.1 << EOF
printf "8\n"
printf $rules > /home/rules;
EOF
This fails and won't log me in or create my file.
If I change it to:
ssh -tt admin@192.168.1.1 << EOF
8
echo -e "$rules" > /home/rules;
exit
0
EOF
I get logged in but my $rules values are echoed to the screen not to the new rules file I want to create.
Any one advise how I can do this?
UPDATE
I've partially got this working by using:
printf "rules" > /home/rules
the only issue with that is $rules
contains a variable which isn't shown in the resulting file.
eg:
$rules="rules information is places in this var.\nis used for new lines\n$additional['rules']['local']";
is written to the file as:
rules information is places in this var.
is used for new lines
['rules']['local']
Note $additional
is missing before ['rules']['local']
Any way I can include that correctly ? I've tried adding \ before $additional, I've tried changing the var so it's not enclosed in " not ' and then updated the single quotes in the string.
Each time I end up with each line from $rules being echoed to the remote command line and not into the remote file.
Any ideas ? Thanks