To connect to your instance you will need to provide your keypair file(pem file). After that, it won't ask for the password. Here's how you do it:
ssh -i /path/keypair.pem username@public_dns_name
In the above command, for path, use the path of your pem file and replace keypair.pem with your key pair pem file.
The username for Ubuntu will be ubuntu and for other instances including Amazon Linux, use ec2-user as the username.