Privacy Fence 4x4 Post against Garage?

I'm building a privacy fence along my north side property line and at the end of each side of the fence, I'll be building gates to match. At one end of the fence is my house where I'll be attaching the opposite gate post to the house, but at the other end is my garage on the opposite side of the fence. On the ground in between my fence and garage I have a sidewalk, but in between my sidewalk and garage, there is about an 8" strip of earth.

Right now, there is a chain link fence that I'll be removing, but I'm worried about how to mount/set the new gate post at the garage end on the garage side. The metal post that is currently there is obviously smaller, but set poorly in the 8" wide strip of earth between the garage and sidewalk.

My question is, how can I securely set the garage side gate post when I'll be using 4x4s and there is only an 8" wide strip of earth between the garage and sidewalk? Should I attach it to the garage too? See attached pics. Thanks!