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.
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.
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/vmware/comm...