Skip to content

Instantly share code, notes, and snippets.

@antoniopicone
Created July 1, 2022 09:55
Show Gist options
  • Save antoniopicone/2d3c6f167c682760a1889507a25e94d8 to your computer and use it in GitHub Desktop.
Save antoniopicone/2d3c6f167c682760a1889507a25e94d8 to your computer and use it in GitHub Desktop.
on:
workflow_dispatch:
jobs:
ssh:
name: "ssh to remote server"
runs-on: ubuntu-latest
steps:
- name: Create SSH Config on temporary VM
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/ssh_key
chmod 600 ~/.ssh/ssh_key
cat >>~/.ssh/config <<END
Host remote_server
HostName $SSH_IP
User $SSH_USER
IdentityFile ~/.ssh/ssh_key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_IP: ${{ secrets.SSH_IP }}
- name: SSH into the server
run: |
ssh remote_server 'ls -l'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment