Skip to content

Commit 4ece635

Browse files
committed
📝 Added logging. Doc cleanup
1 parent 288c992 commit 4ece635

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# v1.1.5
2+
## Features
3+
- Info outputs added to help with debugging workflows (are they adding the key/values correctly?)
4+
- README instructions are less GitLab centric
5+
16
# v1.1.4
27
## Features
38
- Updated GitHub Actions action dependencies

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
77
![Pufferfish](https://gitlab.com/containeryard/openssh/-/raw/14afda69422ca6c4dc91e49cf79de24f0a65b226/avatar.png)
88

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.
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.
1010

1111
## 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+
1215
### Environment Variables
1316

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.):
1518
- `SSH_HOST` (remote's hostname)
1619
- `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)
1921

20-
### Generating SSH_PRIVATE_KEY
22+
### Tool: Generating SSH_PRIVATE_KEY
2123

2224
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").
2325

@@ -27,7 +29,7 @@ docker run --rm mountainash/openssh-client:latest ./keygen.sh
2729

2830
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.
2931

30-
### Getting SSH_KNOWN_HOSTS
32+
### Tip: Getting SSH_KNOWN_HOSTS
3133

3234
SSH to the server and run `ssh-keyscan` on the full domain name of the `SSH_HOST`:
3335

@@ -37,14 +39,14 @@ ssh-keyscan hostname.com
3739

3840
You can also do it locally, but doing it on the server it's self prevents any man-in-the-middle shenanigans.
3941

40-
### GitLab CI/CD Example
42+
### Example: GitLab CI/CD Pipeline
4143

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).
4345

4446
```yml
4547
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
4850
only:
4951
- master
5052
environment:
@@ -58,11 +60,9 @@ deploy:
5860
allow_failure: false
5961
```
6062
61-
`image` can also be pulled from `registry.gitlab.com/containeryard/openssh`
63+
### Example: GitHub Actions Workflow
6264
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.
6666

6767
```yml
6868
name: Deploy to Remote Server
@@ -77,7 +77,7 @@ jobs:
7777
name: Deploy to Remote Server
7878
runs-on: ubuntu-latest
7979
container:
80-
image: registry.gitlab.com/containeryard/openssh
80+
image: mountainash/openssh-client:latest
8181
env:
8282
SSH_HOST: ${{ vars.SSH_HOST }}
8383
SSH_KNOWN_HOSTS: ${{ vars.SSH_KNOWN_HOSTS }}
@@ -90,14 +90,12 @@ jobs:
9090
run: scp /app/sample.html $SSH_USER_NAME@$SSH_HOST:/home/mountainash/www/sitename/index.html
9191
```
9292

93-
`image` can also be pulled from `mountainash/openssh-client:latest` (Docker Hub).
94-
9593
## Contribute
9694

9795
- GitLab: <https://gitlab.com/containeryard/openssh>
9896
- GitHub (mirror): <https://github.com/mountainash/openssh-client>
9997

10098
## Credits
10199

102-
- 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
103101
- Pufferfish by [Catalina Montes from the Noun Project](https://thenounproject.com/term/pufferfish/181192/)

entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ if [ "$SSH_PRIVATE_KEY" ]; then
1111
fi
1212

1313
if [ "$SSH_KNOWN_HOSTS" == "NoStrictHostKeyChecking" ]; then
14+
echo "Info: disabling Strict HostKey Checking"
15+
1416
touch ~/.ssh/config
1517
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config
18+
1619
elif [ "$SSH_KNOWN_HOSTS" ]; then
20+
echo "Info: adding Known Hosts"
21+
1722
touch ~/.ssh/known_hosts
1823
echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
1924
chmod 644 ~/.ssh/known_hosts

0 commit comments

Comments
 (0)