I tried to append a value to the ssh config file but it seems that it doesn't work if specify two different values, it reads the first not the second.
It seems sensible, instead of trying to re-write the entire file, to just modify the value.
Currently the value is:
Port 22
I want to go in and change the value to:
Port 222
The best I can come up with is this:
sed -c -i "s/\(Port *= *\).*/\1$REPLACEMENT_VALUE/" /etc/ssh/sshd_config
However I know this isn't right because it's working in a way where it is expecting to have an equals sign between the value and the variable.
I need the script to do something like this:
- Look for the variable (i.e Port)
- Switch this line with my own line