-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Consider better security defaults #46
Comments
|
Yeah, I think we've been reading the same digitalocean docs ;-) Here's what I've been doing: http://www.carlboettiger.info/2014/09/08/server-security-basics.html Happy to learn more from others. I started drafting a script (very minimal, not working yet) to help automate some of this, though I think it may be hard to automate some steps (e.g. tripwire config, though maybe that's not necessary unless the user is gonna be checking the logs regularly. I'm hoping to get a more professional consultation on this stuff eventually. Computer security is above my pay grade. |
@cboettig thanks for the quick feedback and the script share! |
We still need to consider better security defaults whether or not a user uses docker, right? |
Yes, I think so. I think more functions along the lines of |
right, ok |
I think the first step should be to set up a non-root user. I think we can make this seamless by using
I think using root is fine (for now) inside containers, but we should be a bit stricter at the top level. The only potential downside I see to this is that since we're changing ssh defaults, it may mean some small breakage if you're connecting to a droplet that you created previously. Then apply @cboettig's script to install ufw and set up a minimal firewall. (I think we also need to allow http so that we can talk to RStudio by default) We're already defaulting to using ssh keys if they're available. The main question is if we should require them or not. If required, we need to tweak |
Just a note I've updated my script, though could no doubt be much improved.
(Obviously the script is more of a starting place to adapt than something designed for analogsea directly, just thought I'd note that it was somewhat more useful than it was earlier. Feedback/critique always appreciated) https://github.com/cboettig/dockerfiles/blob/master/setup.sh |
Looks like provides some good suggestions for setting up non root user with sudo privileges: https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup |
Very nice! I really like the approach they take here, that's really how it On Wed, Oct 15, 2014 at 2:00 PM, Hadley Wickham [email protected]
Carl Boettiger |
Is there a significant number we should use for the ssh port? |
Good question. Presumably the function we use will allow the user to choose On Fri, Oct 17, 2014 at 7:25 AM, Hadley Wickham [email protected]
Carl Boettiger |
I don't think we should allow people to choose their own ports. It adds a On Friday, October 17, 2014, Carl Boettiger [email protected]
|
I was thinking flexibility might be more along the lines of a user who just On Fri, Oct 17, 2014 at 10:55 AM, Hadley Wickham [email protected]
Carl Boettiger |
How does this look for a basic config? It:
If we use this system, it will make it harder to access older droplets, because we'll need to change the defaults for user name and ssh port. I think that's ok - it's a one time breaking change, and substantially improves the default security. #cloud-config
users:
- name: analogsea
ssh-authorized-keys:
- ssh-rsa <SSH-KEY>
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
shell: /bin/bash
write_files:
- path: /etc/ssh/sshd_config
content: |
Port 6737
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 1024
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin no
AllowUsers analogsea
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes |
@wch has convinced me that a non-standard port is probably not that important. It adds a lot of extra hassle for only minimal extra security. |
This looks pretty good to me. I think you may need to add |
After a bit more discussion with @wch, we have #cloud-config
users:
- name: analogsea
ssh-authorized-keys:
- ssh-rsa <SSH-KEY>
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
shell: /bin/bash
write_files:
- path: /etc/apt/apt.conf.d/20auto-upgrades
content: |
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
- path: /etc/ssh/sshd_config
content: |
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 1024
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin no
AllowUsers analogsea
StrictModes yes
PasswordAuthentication no
ChallengeResponseAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
runcmd:
- apt-get update
- apt-get install -y unattended-upgrades Compared to the previous version, this:
|
nice! On Mon, Oct 20, 2014 at 2:25 PM, Hadley Wickham [email protected]
Carl Boettiger |
looks great @hadley - should we allow input to modify this setup within |
@sckott I'll make it a little configurable, once I turn it into an R function. But this is a script that's run once on droplet creation, so it's not possible to modify after the fact. |
Do you want to install & configure a On Mon, Oct 20, 2014 at 2:36 PM, Hadley Wickham [email protected]
Carl Boettiger |
@hadley sounds good |
@cboettig I don't think a firewall is sufficiently useful that we should install it by default. |
This now appears to be working - you can use the default ubuntu config with I think the next question is whether we should enable this by default (I think so), and if so, how should we manage the transition? One option is to change the default in |
I like this plan Carl Boettiger sent from mobile device; my apologies for any terseness or typos
|
Hmmm, I wonder why |
late to the party (mostly due to me resurrecting I have empirical evidence (this is part of what I do for a living ;-) that changing the default port to something besides 22 does in fact enhance security greatly. It's a tiny obfuscation step but thwarts a big percentage of opportunistic attackers. It won't stop a determined one but nothing will, so it's worth it to change it. I will agree that having a different universal default ssh port embedded in Why am I blathering on about ports? All my droplets but 1 (which is a partial honeypot as well as a functioning web server) use a different ssh port and was pretty much unable to use @sckott any issues if I (eventually…can't promise a timeline right now) add a |
+1 for other than 22 port - what should that port be? a random port number between number x and y? the |
Aye. It could be a small-ish range, too. We could also add some links to things like https://github.com/fail2ban/fail2ban or add a helper function to install it on images. I'll noodle over some possibilities. |
thanks |
Not sure what these should be. Some ideas:
The text was updated successfully, but these errors were encountered: