An earthquake rattled much of the Northeast on Friday morning, with shaking felt across the New York City metropolitan area and in communities from Baltimore and Philadelphia up through New England.