I have done B2B in Boston and in Fort Lauderdale with little complication, similar to what you can expect in Montreal. To me, the key is to recognize if you are already in the same nation while onboard. USA onboard at a USA port makes it simpler, like spend 20 minutes off the ship, remaining in a hallway just off the gangway.
But in 2023 I did B2B in Vancouver. You are in USA while onboard and must clear Canada customs, then you are in unsecure zone of Canada Place. You go back thru security, US customs and are waiting just like all the new folks arriving to board.
For Montreal you are βin Canadaβ while onboard, so expect a simpler procedure. Watch your instructions to see if you get a special card allowing you to proceed thru the crew lines in terminal.