Home > front end >  Invalid format when using github key
Invalid format when using github key

Time:05-27

I'd like to have files automatically uploaded to my server when using the git push command. But the problem is that it stops at the keys and gives an error ( Load key "/home/runner/.ssh/key": invalid format ). On the hosting, the keys are added, in the settings of the github repository - too. Maybe someone faced similar? How can this problem be solved?

Code:

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Setup key
      - run: set -eu
      - run: mkdir "$HOME/.ssh"
      - run: echo "$" > "$HOME/.ssh/key"
      - run: chmod 600 "$HOME/.ssh/key"
      # Deploy
      - run: rsync -e "ssh -p 1022 -i $HOME/.ssh/key -o StrictHostKeyChecking=no" --archive --compress --delete . *link*/public_html/

CodePudding user response:

Try to change key file and folder .ssh permissions to

  1. .ssh directory: 700 (drwx------)
  2. public key (.pub file): 644 (-rw-r--r--)
  3. private key (id_rsa): 600 (-rw-------)

lastly your home directory should not be writeable by the group or others (at most 755 (drwxr-xr-x))

http://linuxcommand.org/lc3_man_pages/ssh1.html

CodePudding user response:

I fixed the error by changing the output of the key, but the following appeared .. Writes access denied. Here is the updated code:

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Setup key
      - run: set -eu
      - run: mkdir "$HOME/.ssh"
      - run: echo "${{ secrets.key }}" > "$HOME/.ssh/key"
      - run: chmod 600 "$HOME/.ssh/key"
      # Deploy
      - run: rsync -e "ssh -p 1022 -i $HOME/.ssh/key -o StrictHostKeyChecking=no" --archive --compress --delete . *link*/public_html/
  • Related