I am not able to connect to my ec2 server using ssh in circle ci


#1

I have added the private key to circle ci and added following in .circleci/config.yml

tar -zcvf test.tar.gz src/
scp -o "StrictHostKeyChecking=no" test.tar.gz myproject@2.75.83.192:/home/myproject/
ssh myproject@52.75.83.192 tar -xvzf test.tar.gz

After giving permission to port 22 for ip address, I am able to execute these commands. But when disabling the port, the following error is occurs.

src/
src/demo.php
ssh: connect to host 52.75.83.192 port 22: Connection timed out

lost connection
ssh: connect to host 52.75.83.192 port 22: Connection timed out

Exited with code 255

How can I enable the port only for the circle ci?


#2

This is not possible. The build will run from a different IP each time. You would need to whitelist US-East and US-West ranges to do it this way.


#3

Whitelist aws regions. right?
Is there any other better option than, whitelist US-East and US-West ranges.


#4