How to set z position for camera to fit game field

I have a static board that gets generated on game start. I would like to have the camera z distance set so the complete board is always visible doesn’t matter which aspect ratio is used.

I’m using the perspective mode.

Googling did not help me a lot, but I think I used the wrong terms.

Scale the sprite?
here is the guide