Generate an SSH key pair before connecting to a Linux or Mac instance. Connect to your VM using the following command: ssh -i.