Could not able to SSH/(SCP the file) into local machine from the circle

I’m trying to deploy the jar file after building from circle ci by fetching from one of the Github repo into my local machine here are my config file and the steps which I followed.

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See:
version: 2.1
      - image: cimg/openjdk:11.0
      - add_ssh_keys:
            - "a3:72:52:7d:19:e4:41:16:f1:87:ed:84:01:f9:d8:c0" // finger print ID 
      - checkout
      - run:
          name: Build
          command: mvn -B -DskipTests clean package
      - run:
          name: Test
          command: mvn test
      - run:
          name: Deploy Over SSH
          command: |
            scp -r /home/circleci/project/target/HelloWorld-1.0-SNAPSHOT.jar manjunathdavanam@$local_machine_ip_address:/Users/manjunathdavanam/test
      - build-and-test
  1. I have generated an ssh key from my local machine using this command ssh-keygen -t ed25519 -C email_id
  2. After creating an ssh key, Click on the project settings and add ssh key which is got generated from local and then after adding it will generate a fingerprint.
  3. I have copied the fingerprint id and pasted it into my config.yml file.
  4. I’m trying to copy the HelloWorld-1.0-SNAPSHOT.jar file into my local machine test folder using scp command. scp -r /home/circleci/project/target/HelloWorld-1.0-SNAPSHOT.jar davanam@$local_machine_ip_address:/Users/manjunathdavanam/test
  5. I’m using mac laptop I have enabled the remote login = true and `allow access for all users in the system preferences sharing section.
  6. for testing I tried to ssh from my local machine then I’m able to log in to the local machine.
  7. Now, I did ssh to circle the ci machine and tried ssh -v username@ipaddress inside the circle ci machine but I’m getting a time out error
  8. I have also checked the ssh config file inside the circle ci machine it’s pointed to the right key. cat /home/circleci/.ssh/config

Host ! *
  IdentitiesOnly no
  IdentityFile /home/circleci/.ssh/id_rsa_a373527d19e44616f18fdf4328ed8401f

Could you please help me here what’s wrong with my config file? Why I’m not able to SCP
the file from circle ci machine to my local machine. ?


We believe the issue is that you are trying to use an internal IP and not an external IP, as CircleCI is an external network to where you are running SCP it does not know about your internal IP.

Would it be possible to change your script to the script below, replacing the external IP with your external IP address. We have also added the -v to give verbose logging but if you are not happy posting the output of this please feel free to open a support ticket.

scp -v -r -i ~/.ssh/id_rsa manjunathdavanam@externalIP:"/Users/manjunathdavanam/test"

Please be aware by default it will try to use port 22 to connect to your network which can cause issues if this port is not open.