name: remote ssh command
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: whoami
SSH Remote Commands
SSH for GitHub Action
What is Remote SSH Commands?
The GitHub Remote Commands action supports those using a Linux operating system within a Docker container. It involves a few steps, such as accessing the main computer, providing a username and password, among others. There are also examples of how to accomplish this using SSH keys.
To delve a bit deeper, key parameters include the main computer address, port number, username, password, and SSH key. By using the action, we can log in with a specific username and password to execute commands at a specific address.
Additionally, besides logging in with SSH keys, it's essential to create a private key and copy it from where it was generated to another location. This is crucial for security purposes and should be done using GitHub Secrets.
Overall, this action provides GitHub Actions users with the flexibility to execute SSH commands on remote servers within their projects. It also offers guidance on securely creating and using SSH keys.
Tabii, işte her bir "How to" başlığı altındaki kodları yorumlayarak eklemiş olduğum geliştirilmiş açıklamalar:
How to execute remote ssh commands using password?
- name: executing remote ssh commands using password
uses: appleboy/ssh-[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: whoami
This action allows executing SSH commands on a remote server using password-based authentication. It's essential for scenarios where using SSH keys isn't feasible or preferred due to security reasons or system configurations.
How to use private key in GitHub Actions SSH?
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: whoami
This action demonstrates executing SSH commands using a private key for authentication. Using SSH keys provides a more secure and convenient method compared to passwords, especially in automated workflows.
Multiple Commands
- name: multiple command
uses: appleboy/ssh-[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
whoami
ls -al
Demonstrates executing multiple commands sequentially on the remote server via SSH. This feature is useful for performing complex tasks or executing scripts on the target system.
How to use multiple hosts in GitHub Actions ssh?
- name: multiple host
uses: appleboy/ssh-[email protected]
with:
- host: "foo.com"
+ host: "foo.com,bar.com"
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
whoami
ls -al
Shows how to execute commands on multiple hosts using SSH within GitHub Actions workflows. This capability is valuable for distributed systems or environments requiring management across various servers.
How to use multiple hosts with different port in GitHub Actions ssh?
- name: multiple host
uses: appleboy/ssh-[email protected]
with:
- host: "foo.com"
+ host: "foo.com:1234,bar.com:5678"
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
whoami
ls -al
Illustrates executing commands on multiple hosts with different port numbers using SSH. This flexibility is crucial for scenarios where servers use non-standard SSH port configurations.