You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can be used in a deployment pipeline to connect to a remote host, and run a git, a Docker `pull` or any CLI command.
9
+
Can be used in a deployment pipeline to connect to a remote host, and run a git, a Docker `pull` or any CLI command. It's very small and lightweight, based on Alpine Linux.
10
10
11
11
## Setup
12
+
13
+
Image available on [Docker Hub](https://hub.docker.com/r/mountainash/openssh-client) or [GitLab Container Registry](https://gitlab.com/containeryard/openssh/container_registry/1422252).
14
+
12
15
### Environment Variables
13
16
14
-
These variables are set in GitLab CI/CD settings (but could be any CI/CD pipeline service eg. GitHub Actions, CircleCI, Jenkins, etc.):
17
+
These variables are set in the CI/CD settings (these could be any CI/CD pipeline service eg. GitHub Actions, GitLab CI/CD, CircleCI, Jenkins, etc.):
15
18
-`SSH_HOST` (remote's hostname)
16
19
-`SSH_KNOWN_HOSTS` (host's key signature eg. `[172.31.98.99]:22222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE...n9K9hnplyRGA3MJfe/wBoCVIaX`, can be set to `NoStrictHostKeyChecking` to not check)
17
-
-`SSH_USER_NAME` (ssh username for access to the host)
18
-
-`SSH_PRIVATE_KEY` (ssh private key for SSH_USER_NAME)
20
+
-`SSH_PRIVATE_KEY` (SSH private key added to the agent store)
19
21
20
-
### Generating SSH_PRIVATE_KEY
22
+
### Tool: Generating SSH_PRIVATE_KEY
21
23
22
24
Need some new keys? You can use this image to generate them (no polluting up your local machine with keys - and adding to your "vector").
23
25
@@ -27,7 +29,7 @@ docker run --rm mountainash/openssh-client:latest ./keygen.sh
27
29
28
30
Four different types (dsa, ecdsa, ed25519, or rsa) public and private authentication keys will be printed to stdout. Pick your perferred key type and copy & paste into your CD/CI settings and remote server.
29
31
30
-
### Getting SSH_KNOWN_HOSTS
32
+
### Tip: Getting SSH_KNOWN_HOSTS
31
33
32
34
SSH to the server and run `ssh-keyscan` on the full domain name of the `SSH_HOST`:
33
35
@@ -37,14 +39,14 @@ ssh-keyscan hostname.com
37
39
38
40
You can also do it locally, but doing it on the server it's self prevents any man-in-the-middle shenanigans.
39
41
40
-
### GitLab CI/CD Example
42
+
### Example: GitLab CI/CD Pipeline
41
43
42
-
Create a `.gitlab-ci.yml` file in the root of your project to trigger SSH commands on a remote server on commit to the `master` branch.
44
+
Create a `.gitlab-ci.yml` file in the root of your project to trigger SSH commands on a remote server and commit to the `master` branch (pre-cloning on the server would already be needed).
43
45
44
46
```yml
45
47
deploy:
46
-
## Replace latest with a SHA for better security
47
-
image: mountainash/openssh-client:latest
48
+
## Suffix with latest with a SHA for better security
49
+
image: registry.gitlab.com/containeryard/openssh
48
50
only:
49
51
- master
50
52
environment:
@@ -58,11 +60,9 @@ deploy:
58
60
allow_failure: false
59
61
```
60
62
61
-
`image` can also be pulled from `registry.gitlab.com/containeryard/openssh`
63
+
### Example: GitHub Actions Workflow
62
64
63
-
### GitHub Actions Workflow Example
64
-
65
-
In `./github/workflows/ssh-deploy.yml` (or similar).
65
+
In `./github/workflows/ssh-deploy.yml` (or similar). This will copy a file to a remote server on a push to the `main` branch.
- Based on <https://github.com/chuckyblack/docker-openssh-client> / <https://hub.docker.com/r/jaromirpufler/docker-openssh-client> but added host keys support
100
+
- Based on <https://github.com/chuckyblack/docker-openssh-client> / <https://hub.docker.com/r/jaromirpufler/docker-openssh-client> but added host keys support & keygen script
103
101
- Pufferfish by [Catalina Montes from the Noun Project](https://thenounproject.com/term/pufferfish/181192/)
0 commit comments