본문 바로가기

AWS

[AWS] Access aws via SSH in Mac's terminal

Connect to EC2 instance from terminal in Mac.


1) Key pair의 access mode를 변경해준다. 여기서는 400으로 변경

MacBook-Pro:ssh ryanlee$ chmod 400 my_ec2_key_pair.pem


2) login from terminal ec2-user는 username. 54.241.142.18은 ec2 instance public IP

[ec2-user@ip-172-31-5-35 ~]$ ssh ec2-user@54.241.142.18 -i my_ec2_key_pair.pem


3) Install http demon

[ec2-user@ip-172-31-5-35 ~]$ sudo yum install httpd -y


4) 다음으로 /var/www/html 로 이동하여 index.html을 하나 만들어준다. 

[root@ip-172-31-5-35 ec2-user]# cd /var/www/html

[root@ip-172-31-5-35 html]# ls

[root@ip-172-31-5-35 html]# nano index.html

[root@ip-172-31-5-35 html]# ls -al


5) httpd start를 한다. 

[root@ip-172-31-5-35 html]# service httpd start


6) 그 다음은 웹브라우저 띄워서 들어가서 확인해보면 잘 되는 것을 확인가능