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 }}
-
name
RequiredA unique name for the server config entry.
-
host
RequiredThe host address.
-
port
Default: '22'SSH port.
-
user
RequiredAn user.
-
private-key
RequiredPrivate SSH key for the user.
-
fail-if-entry-already-exists
Default: '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-name
The 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.com
on port 22 - use the
deploy
user 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.com
on port 2222 - use the
ubuntu
user 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
~/.ssh
exists 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}.key
with 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.