Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Issue with script in Photon OS
Post Body

I'm trying to automate a STIG check for our Vcenter appliance but having an issue with doing a nested if statement, perhaps there are some experts here that can help. I've tried flipping between single and double quotes and changed things around a couple times and it works line by line but I cannot get it working as a script. Current code:

#!/bin/bash

sFile='/root/sshd_config' #Vuln 123456

if [[ -f $sFile ]]

then

echo 'file existgs'

if grep '#UsePAM no' $sFile

then

echo 'setting exists'

sed -i 's/#UsePAM no/#UsePAM yes/' $sFile

fi

else

echo 'file doesnt exist'

fi

I know there has to be something simple I'm missing, unless the shell inside is stripped down in some way?

Edit: I'm a dunce, I typed '#UsePAM' in here but when I reread last night in the VM I had '$UsePam' so the grep was never matching.

Author
Account Strength
90%
Account Age
9 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,174
Link Karma
215
Comment Karma
3,959
Profile updated: 3 days ago
Posts updated: 3 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago