Coder Social home page Coder Social logo

Comments (9)

ruudk avatar ruudk commented on May 23, 2024 1

I need both, I'm using an app that checks if the key is on disk + requires it to be in ssh-agent later (because of git push somewhere in the process). So that's kinda silly. But maybe it's an edge case.

from ssh-key-action.

shimataro avatar shimataro commented on May 23, 2024 1

@kceb

I also have to add the following after the script because it seems that github secrets don't respect new lines at the end:

Yes, framework of action trims whitespaces.
https://github.com/actions/toolkit/blob/d17d4a916377cc569a5c642b9d2f56c23d1ab620/packages/core/src/core.ts#L67-L74

My action prepends LF to secrets. So, it is not a problem as long as this action is used at last.

By the way, ssh-add is not necessary in order to use private repo.
Below workflow will work.

steps:
- name: Install SSH key
  uses: shimataro/ssh-key-action@v2
  with:
    key: ${{ secrets.SSH_KEY }} # your private key
    known_hosts: |
      bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
- name: Clone private repo from Bitbucket
  run: git clone [email protected]:YOUR/REPOSITORY.git

from ssh-key-action.

shimataro avatar shimataro commented on May 23, 2024

@ruudk
Do you mean that you want to launch ssh-agent and add keys using ssh-add?
As far as I researched, webfactory/ssh-agent can do it.

from ssh-key-action.

ruudk avatar ruudk commented on May 23, 2024

Yeah, I've been using both actions now, feels like 1 action could do both things.

from ssh-key-action.

shimataro avatar shimataro commented on May 23, 2024

@ruudk
Sorry, let me make sure what you mean again.

You want to:

  • launch ssh-agent, and
  • load your keys to the memory using ssh-add

Is that all?
If so, you won't need my action. webfactory/ssh-agent is enough.

Or, also want to add keys in ~/.ssh or do something else?

from ssh-key-action.

shimataro avatar shimataro commented on May 23, 2024

@ruudk

requires it to be in ssh-agent later (because of git push somewhere in the process)

ssh-agent is not necessary for git push, this action (Install SSH Key) is enough.

from ssh-key-action.

kceb avatar kceb commented on May 23, 2024

I also ran into this issue (because I need to pull a private bitbucket repo) and had to manually add

ssh-add -K ~/.ssh/id_rsa

I also have to add the following after the script because it seems that github secrets don't respect new lines at the end:

        echo "" >> ~/.ssh/id_rsa
        echo "" >> ~/.ssh/known_hosts

not adding the above two lines causes ssh-add to fail and also causes known_hosts to be invalid when other hosts get added.

from ssh-key-action.

kceb avatar kceb commented on May 23, 2024

@shimataro thanks

could you clarify the following?

My action prepends LF to secrets. So, it is not a problem as long as this action is used at last.

I'm still facing issues when I use key: ${{ secrets.SSH_KEY }} # your private key, I find that I have to still append a newline to the id_rsa file.

my setup:

    - name: Install SSH key
      uses: shimataro/ssh-key-action@v2
      with:
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        name: id_rsa
        known_hosts: |
          bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
    - name: Format SSH key and add to agent
      run: |
        chmod 600 ~/.ssh/id_rsa
        echo "" >> ~/.ssh/id_rsa
        echo "" >> ~/.ssh/known_hosts # I find I need this if I use something like this later on in the workflow: https://github.com/marketplace/actions/debugging-with-tmate

from ssh-key-action.

shimataro avatar shimataro commented on May 23, 2024

@kceb

I'm still facing issues when I use key: ${{ secrets.SSH_KEY }} # your private key, I find that I have to still append a newline to the id_rsa file.

Yes, my action just prepends newline, not appends.
If you need to edit something to known_hosts, please use any one of the followings.

  • run echo "" >>~/.ssh/known_hosts after installing SSH key, as you wrote
  • edit known_hosts before using my action

echo "" >> ~/.ssh/id_rsa

Is there a necessity to append newline to id_rsa?

from ssh-key-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.