Skip to content

Improve SSH #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
54d999e
Initial commit of deploy for testing
jaydrogers May 7, 2024
568e97b
Changed to deploy
jaydrogers May 7, 2024
345d218
Set dbeug
jaydrogers May 7, 2024
ae91c58
Update build settings and playbook SSH port handling
jaydrogers May 7, 2024
2bf7fbd
Refactor playbook SSH port handling to use the ssh_port variable
jaydrogers May 7, 2024
5d9aff1
Refactor playbook SSH port handling to use the ssh_port variable
jaydrogers May 7, 2024
d773867
Refactor playbook SSH port handling to use the ssh_port variable
jaydrogers May 7, 2024
c81397b
Refactor playbook SSH port handling to use the ssh_port variable
jaydrogers May 7, 2024
836d68f
Refactor playbook SSH port handling to remove unnecessary ssh_port va…
jaydrogers May 7, 2024
560ff0c
Refactor playbook SSH port handling to fix ansible_ssh_common_args typo
jaydrogers May 7, 2024
21739ab
Refactor playbook SSH port handling to use the ssh_port variable
jaydrogers May 8, 2024
2887c6b
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
5f32cf2
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
3aac459
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
ecb10e5
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
22c84d2
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
bf0af49
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
4b0f23c
Refactor playbook SSH port handling and update build settings
jaydrogers May 8, 2024
67fe52f
Refactor playbook SSH port handling and add project_path variable
jaydrogers May 8, 2024
2f6c1ab
Remove deploy
jaydrogers May 8, 2024
6328bc7
Refactor playbook SSH port handling and add project_path variable
jaydrogers May 8, 2024
cc8d8db
Set to all
jaydrogers May 8, 2024
aa3c661
Refactor SSH configurations and enable TCP forwarding and gateway ports
jaydrogers May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .spin.example.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,9 @@
server_timezone: "Etc/UTC"
server_contact: [email protected]

# SSH
# If you the SSH port below, you may need to run `spin provision -p <your-default-ssh-port>`
# to get a connection on your first provision. Otherwise, SSH will try connecting
# to your new port before the SSH server configuration is updated.
ssh_port: "22"

## Email Notifications
@@ -58,4 +60,4 @@ docker_user:
# groups: ['adm','sudo']
# shell: "/bin/bash"
# authorized_keys:
# - public_key: "ssh-ed25519 AAAAC3NzaC1anotherfakekeyIMVIzwQXBzxxD9b8Erd1FKVvu bob"
# - public_key: "ssh-ed25519 AAAAC3NzaC1anotherfakekeyIMVIzwQXBzxxD9b8Erd1FKVvu bob"
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

9 changes: 3 additions & 6 deletions playbooks/provision.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
---
- name: Setup and provision Docker Swarm servers with Spin.
hosts: '{{ target | default("all") }}'
remote_user: '{{ remote_user | default("root") }}'
hosts: "{{ target | default('all') }}"
remote_user: "{{ ansible_user | default('root') }}"
become: true
vars:
ansible_port: "{{ ssh_port }}"
ansible_ssh_common_args: "-o IgnoreUnknown=UseKeychain"
pre_tasks:
- name: Set ansible_ssh_port
set_fact:
ansible_ssh_port: "{{ ssh_port }}"
roles:
- serversideup.spin.linux_common
- serversideup.spin.swarm
2 changes: 2 additions & 0 deletions roles/linux_common/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ server_contact: [email protected]
ssh_port: "22"
ssh_permit_root_login: "no"
ssh_password_authentication: "no"
ssh_allow_tcp_forwarding: "yes"
ssh_gateway_ports: "yes"


## Email Notifications
9 changes: 6 additions & 3 deletions roles/linux_common/tasks/security.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
- name: Ensure secure SSH config is up to date.
- name: Ensure SSH configurations are up to date.
ansible.builtin.template:
src: "etc/ssh/sshd_config.d/spin-secure-ssh.conf.j2"
dest: "/etc/ssh/sshd_config.d/spin-secure-ssh.conf"
src: "etc/ssh/sshd_config.d/{{ item }}.j2"
dest: "/etc/ssh/sshd_config.d/{{ item }}"
owner: root
group: root
mode: 0644
notify: Restart ssh
with_items:
- spin-secure-ssh.conf
- spin-ssh-tunnels.conf

- name: Open the firewall port for SSH.
community.general.ufw:
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ ansible_managed }}
AllowTcpForwarding {{ ssh_allow_tcp_forwarding }}
GatewayPorts {{ ssh_gateway_ports }}
10 changes: 9 additions & 1 deletion roles/swarm/tasks/configure-docker-user.yml
Original file line number Diff line number Diff line change
@@ -21,4 +21,12 @@
state: present
key: "{{ item }}"
with_items: "{{ docker_user.authorized_ssh_keys }}"
when: docker_user.authorized_ssh_keys is defined
when: docker_user.authorized_ssh_keys is defined

- name: Add public keys of admin or sudo users to Docker user
ansible.posix.authorized_key:
user: "{{ docker_user.username }}"
state: present
key: "{{ item.authorized_keys.0.public_key }}"
loop: "{{ users }}"
when: "'adm' in item.groups or 'sudo' in item.groups"