forked from trailofbits/algo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change default SSH port and introduce cloud-init support (trailofbits…
…#1636) * Change default SSH port * Iptables to ansible_ssh_port * Add Scaleway * permissions and groups fixes * update firewall docs * SSH fixes * add missing cloudinit to cloud-azure * remove ansible_ssh_user from the tests * congrats message fix
- Loading branch information
1 parent
b66c9f5
commit d635c76
Showing
25 changed files
with
229 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ You can now set up clients to connect to your VPN. Proceed to [Configure the VPN | |
"# Local DNS resolver 172.16.0.1 #" | ||
"# The p12 and SSH keys password for new users is XXXXXXXX #" | ||
"# The CA key password is XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #" | ||
"# Shell access: ssh -i configs/algo.pem [email protected] #" | ||
"# Shell access: ssh -F configs/<server_ip>/ssh_config algo #" | ||
``` | ||
## Configure the VPN Clients | ||
|
@@ -151,17 +151,17 @@ Depending on the platform, you may need one or multiple of the following files. | |
|
||
If you turned on the optional SSH tunneling role, then local user accounts will be created for each user in `config.cfg` and SSH authorized_key files for them will be in the `configs` directory (user.ssh.pem). SSH user accounts do not have shell access, cannot authenticate with a password, and only have limited tunneling options (e.g., `ssh -N` is required). This ensures that SSH users have the least access required to setup a tunnel and can perform no other actions on the Algo server. | ||
|
||
Use the example command below to start an SSH tunnel by replacing `user` and `ip` with your own. Once the tunnel is setup, you can configure a browser or other application to use 127.0.0.1:1080 as a SOCKS proxy to route traffic through the Algo server. | ||
Use the example command below to start an SSH tunnel by replacing `<user>` and `<ip>` with your own. Once the tunnel is setup, you can configure a browser or other application to use 127.0.0.1:1080 as a SOCKS proxy to route traffic through the Algo server. | ||
|
||
`ssh -D 127.0.0.1:1080 -f -q -C -N user@ip -i configs/<server_ip>/ssh-tunnel/<user>.pem` | ||
`ssh -D 127.0.0.1:1080 -f -q -C -N <user>@algo -i configs/<ip>/ssh-tunnel/<user>.pem -F configs/<ip>/ssh_config` | ||
|
||
## SSH into Algo Server | ||
|
||
Your Algo server is configured for key-only SSH access for administrative purposes. Open the Terminal app, `cd` into the `algo-master` directory where you originally downloaded Algo, and then use the command listed on the success message: | ||
|
||
`ssh -i configs/algo.pem user@ip` | ||
`ssh -F configs/<ip>/ssh_config algo` | ||
|
||
where `user` is either `root` or `ubuntu` as listed on the success message, and `ip` is the IP address of your Algo server. If you find yourself regularly logging into the server then it will be useful to load your Algo ssh key automatically. Add the following snippet to the bottom of `~/.bash_profile` to add it to your shell environment permanently. | ||
where `<ip>` is the IP address of your Algo server. If you find yourself regularly logging into the server then it will be useful to load your Algo ssh key automatically. Add the following snippet to the bottom of `~/.bash_profile` to add it to your shell environment permanently. | ||
|
||
`ssh-add ~/.ssh/algo > /dev/null 2>&1` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
apt-get update -y | ||
apt-get install sudo -y | ||
|
||
getent passwd algo || useradd -m -d /home/algo -s /bin/bash -G adm,netdev -p '!' algo | ||
|
||
(umask 337 && echo "algo ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/10-algo-user) | ||
|
||
cat <<EOF >/etc/ssh/sshd_config | ||
{{ lookup('template', 'files/cloud-init/sshd_config') }} | ||
EOF | ||
|
||
test -d /home/algo/.ssh || (umask 077 && sudo -u algo mkdir -p /home/algo/.ssh/) | ||
echo "{{ lookup('file', '{{ SSH_keys.public }}') }}" | (umask 177 && sudo -u algo tee /home/algo/.ssh/authorized_keys) | ||
|
||
sudo apt-get remove -y --purge sshguard || true | ||
systemctl restart sshd.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#cloud-config | ||
output: {all: '| tee -a /var/log/cloud-init-output.log'} | ||
|
||
package_update: true | ||
package_upgrade: true | ||
|
||
packages: | ||
- sudo | ||
|
||
users: | ||
- default | ||
- name: algo | ||
homedir: /home/algo | ||
sudo: ALL=(ALL) NOPASSWD:ALL | ||
groups: adm,netdev | ||
shell: /bin/bash | ||
lock_passwd: true | ||
ssh_authorized_keys: | ||
- "{{ lookup('file', '{{ SSH_keys.public }}') }}" | ||
|
||
write_files: | ||
- path: /etc/ssh/sshd_config | ||
content: | | ||
{{ lookup('template', 'files/cloud-init/sshd_config') | indent(width=6) }} | ||
runcmd: | ||
- set -x | ||
- sudo apt-get remove -y --purge sshguard || true | ||
- systemctl restart sshd.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Port {{ ssh_port }} | ||
AllowGroups algo | ||
PermitRootLogin no | ||
PasswordAuthentication no | ||
ChallengeResponseAuthentication no | ||
UsePAM yes | ||
X11Forwarding yes | ||
PrintMotd no | ||
AcceptEnv LANG LC_* | ||
Subsystem sftp /usr/lib/openssh/sftp-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.