I am traveling from Boston to Canada by cruise ship. The first port of arrival is on July 30 and the last port in Canada is on August 4. Then I'm flying on August 5 from Montreal to California. My passport is valid until August 20th. Will I have a problem?
Canada does not have a six-month passport validity requirement, as some countries do. The US waives its six-month requirement for most countries, and it does not in any event apply to US citizens or permanent residents, nor even to certain classes of nonimmigrants living in the US.
You are therefore unlikely to have a problem related to the expiration of your passport.
With regard to Canada, I quote from my answer to a similar question:
I have no reference for this except to say that the six-month requirement is to be found nowhere at any of the following pages:
If you are a nonimmigrant in the US, please leave a comment noting your status and I'll expand the answer accordingly.