Comments (9)
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.
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.
@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.
Yeah, I've been using both actions now, feels like 1 action could do both things.
from ssh-key-action.
@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.
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.
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.
@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.
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 theid_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)
- Does the ssh key get left on the runner? HOT 8
- Feature Request: Allow multiple keys to be setup for a single remote host HOT 1
- Permission denied (publickey) for git clone HOT 1
- Error loading key "/home/runner/.ssh/deploy_key": invalid format while format is RSA HOT 1
- python2 error HOT 2
- Update Node.js warning HOT 6
- Node 12 is deprecated HOT 2
- Make known_hosts optional HOT 2
- Deleting .ssh directory on self hosted runner is terrible HOT 5
- Remove only specific ssh key after execution HOT 6
- Rsync fails Permission denied (publickey) HOT 2
- Github SSH key has not been updated HOT 1
- Feature Request: strip cr/lf endings from ssh key HOT 1
- panic: ssh tcp to server: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
- Cannot connect to SSH via Github action HOT 4
- Error on run `ssh-keyscan` HOT 1
- Syntax for known_hosts HOT 1
- Node.js 16 actions are deprecated HOT 1
- ssh-key-action step failing with GLIBC not found error HOT 2
- Host key verification failed. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssh-key-action.