A GitHub Action to create a new ssh/config entry for given host
- uses: cdqag/action-configure-ssh-host@v1
with:
name: my-server
host: example.com
port: 22
user: deploy
private-key: ${{ secrets.SSH_PRIVATE_KEY }}-
nameRequiredA unique name for the server config entry.
-
hostRequiredThe host address.
-
portDefault: '22'SSH port.
-
userRequiredAn user.
-
private-keyRequiredPrivate SSH key for the user.
-
fail-if-entry-already-existsDefault: 'true'If set to
true, the action will fail if the SSH config entry already exists. If set tofalse, it will skip the rest of the steps.
-
server-nameThe name for the server in the config (sanitized version of the input name).
This example will:
- create an SSH config entry named
production-server - configure connection to
prod.example.comon port 22 - use the
deployuser for authentication - use the private key from secrets
- uses: cdqag/action-configure-ssh-host@v1
with:
name: production-server
host: prod.example.com
user: deploy
private-key: ${{ secrets.SSH_PRIVATE_KEY }}This example will:
- create an SSH config entry named
staging-server - configure connection to
staging.example.comon port 2222 - use the
ubuntuuser for authentication - use the private key from secrets
- uses: cdqag/action-configure-ssh-host@v1
with:
name: staging-server
host: staging.example.com
port: 2222
user: ubuntu
private-key: ${{ secrets.SSH_PRIVATE_KEY }}This action:
- Sanitizes the server name - converts the provided name to a safe format for SSH config
- Creates SSH directory - ensures
~/.sshexists with proper permissions (700) - Checks for duplicates - verifies the host entry doesn't already exist in SSH config
- Creates private key file - saves the private key to
~/.ssh/{server-name}.keywith secure permissions (600) - Scans host keys - adds the server's public keys to
~/.ssh/known_hosts - Creates SSH config entry - adds a new Host entry to
~/.ssh/config
After running this action, you can connect to your server using:
ssh {server-name}- This action is based on invi5H/ssh-action, but it seems abandoned and not maintained anymore.
This project is licensed under the MIT License. See the LICENSE file for details.