Follow below steps to connect to ec2 instance and make file transfer from mac terminal.
1.download the keypair to mac [ in our case awskeypair.pem ]
2.change the permission to 400
chmod 400 /path/awskeypair.pem
3.open terminal on mac by searching on spotlight search
Enter the following command into the terminal.
ssh -i awskeypair.pem firstname.lastname@example.org
After the first login to the EC2, you do not need to repeat the chmod to change permissions for the key. Every time you start an previously-stopped EC2 instance, there will be a new Public DNS. To connect to the EC2 after the first login, copy and paste that new Public DNS on the above command.
4.Copy the files to ec2 instance . Enter the following command into the terminal.
scp -i awskeypair.pem test.txt email@example.com:/tmp
5.Verify the file test.txt transferred to the server .