First you need to create a support ticket or contact support to enable shell access.

Then, open up your terminal app and type

ssh -p 2222 cpanelusr@ip.add.re.ss

You use your cPanel login credentials to access the server.

How Do I Get and Use SSH Access? « HostGator.com Support Portal

via How Do I Get and Use SSH Access? « HostGator.com Support Portal.