How long can you live on a mechanical ventilator?

60+ years. In some cases people can lives years or decades on a ventilator. One can potentially live their whole life on a ventilator and die from other causes.
Indefinitely. Depending on the cause of respiratory failure and other ongoing medical problems, patients can live for years on mechanical ventilation. Stephen hawkings, the brilliant physicist has lived for years on mechanical ventilation with a severe neuromuscular disease.
Possibly years... There are patients who live for years on a ventilator. These patients do require a lot of care and it is often difficult to care for these patients at home. There are chronic ventilator units in many long term care settings so these patients can receive the care they need to live for years in the best quality possible. Not all live for years but many do. Longevity depends on many factors.
As long as possible. So long as lungs are supported by a ventilator, and if all other organs are functioning on par- theoretically they can be on ventilator for ever.