Coder Social home page Coder Social logo

Comments (7)

shimataro avatar shimataro commented on May 24, 2024 1

Hi,
I added if_key_exists parameter on feature/if_key_exists branch.

You can test it by using shimataro/ssh-key-action@feature/if_key_exists.

runs-on: ubuntu-latest
steps:
- name: Install SSH key
  uses: shimataro/ssh-key-action@feature/if_key_exists
  with:
    key: ${{ secrets.SSH_KEY }}
    known_hosts: ${{ secrets.KNOWN_HOSTS }}
    if_key_exists: replace # replace / ignore / fail; optional (defaults to fail)

from ssh-key-action.

lucasdemarchi avatar lucasdemarchi commented on May 24, 2024

Not ideal, but I "fixed" this by just adding a step to remove the file

from ssh-key-action.

chenghuang-mdsol avatar chenghuang-mdsol commented on May 24, 2024

yep. there should be something to make ssh agent to use a precleaned temp folder.

from ssh-key-action.

shimataro avatar shimataro commented on May 24, 2024

Very sorry for late response.

Could you show me reproducible repository, especially YAML file for GitHub Actions?

from ssh-key-action.

dcfsc avatar dcfsc commented on May 24, 2024

We are using self-hosted GitHub Action runners and they do not start from a brand new runner each time. Files left in the home directory persist. Ours are Linux, but the same issue.

    steps:
      - name: Setup Node 12
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Install SSH key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.ID_GITHUB_ACTIONS_MACHINE_USER_RSA }}
          name: id_rsa # optional
          known_hosts: ${{ secrets.SSH_KNOWN_HOST }}

The first run creates the ~/.ssh/id_rsa file with the valid private key.

The second run fails as mentioned:

Run shimataro/ssh-key-action@v2
  with:
    key: ***
    name: id_rsa
    known_hosts: ***
Error: EEXIST: file already exists, open '/home/admin/.ssh/id_rsa'

an option might allow ignoring this situation and completing the build:

- name: Install SSH key
  uses: shimataro/ssh-key-action@v2
  with:
    key: ${{ secrets.ID_GITHUB_ACTIONS_MACHINE_USER_RSA }}
    name: id_rsa # optional
    known_hosts: ${{ secrets.SSH_KNOWN_HOST }}
    if_exists: replace < if file exists, replace the existing key>
 OR 
    if_exists: ignore <if file exists, do not replace >
DEFAULT
    if_exists: fail  < if file exists, fail>

This would allow us to create a key when on a new self-hosted runner, but continue when the key has already been created.

In either case, the Action would then just install the key into ssh-agent as now.

from ssh-key-action.

shimataro avatar shimataro commented on May 24, 2024

@dcfsc

Files left in the home directory persist.

Thank you for the information, It must be a cause!

- name: Install SSH key
  uses: shimataro/ssh-key-action@v2
  with:
    key: ${{ secrets.ID_GITHUB_ACTIONS_MACHINE_USER_RSA }}
    name: id_rsa # optional
    known_hosts: ${{ secrets.SSH_KNOWN_HOST }}
    if_exists: replace < if file exists, replace the existing key>
 OR 
    if_exists: ignore <if file exists, do not replace >
DEFAULT
    if_exists: fail  < if file exists, fail>

It's a good idea! Thank you again!

from ssh-key-action.

shimataro avatar shimataro commented on May 24, 2024

v2.3.0 has been released, now if_key_exists option is available!
closing.

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.