Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Grump posted:

Because I just want to idk. This isn't like a production server with valuable stuff on it.

Anyway, I got it working. I can now use a pub key for both root and user. Thanks for the help guys!


I have an SSL for my website.

Is it for like ansible testing or what? You can sudo to root. I get it’s for fun but like let us help you show you the right way to do this for production stuff.

Adbot
ADBOT LOVES YOU

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Should I just turn off password authentication and root user login in the sshd_config file then?

jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Grump posted:

Should I just turn off password authentication and root user login in the sshd_config file then?

Ideally yes. You login as your user and sudo when you need root.

Try to do as much as you can as your user. You’ll see you can do a bunch of stuff as your user. Being root all the time is a bad habit.

jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Maybe I won’t go as far as disabling password auth because it’s still a nice fallback when you don’t have your laptop or workstation handy but yeah disable root. Look at your auth log. You’ll see millions of failures of logging in via ssh as root.

Assuming this is a public server.

RFC2324
Jun 7, 2012

http 418

maybe edit sudoers to prevent root shell at all so you have to use the sudo command for all root commands.

Volguus
Mar 3, 2009

RFC2324 posted:

maybe edit sudoers to prevent root shell at all so you have to use the sudo command for all root commands.

ouch. that's too far.

jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Good habit though. Horribly frustrating but a good habit

G-Prime
Apr 30, 2003

Baby, when it's love,
if it's not rough it isn't fun.
There are so many things you have to exclude to fully prevent it, though. All the various shells, plus anything that can execute arbitrarily. Vim is a great example. If I can sudo vim, from inside I can :!bash, and now I'm in a root shell. I mean, yes, it's a good practice, but it's impractical and doesn't actually gain you anything but frustration.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
I'm completely lost in regards to running a cron job in crontab to auto renew my SSL. I'm currently running this command

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && ./path/to/certbot-auto renew

and I can see that it's run in the cron logs, but I don't have any mail server set up, so I can't see if there's any errors. Is there some way to easily email myself the logs in the command line without having a mail server set up?

RFC2324
Jun 7, 2012

http 418

G-Prime posted:

There are so many things you have to exclude to fully prevent it, though. All the various shells, plus anything that can execute arbitrarily. Vim is a great example. If I can sudo vim, from inside I can :!bash, and now I'm in a root shell. I mean, yes, it's a good practice, but it's impractical and doesn't actually gain you anything but frustration.

it breaks the habit of becoming root. if you are going for security instead of just breaking bad habits, then there are better ways of locking root down.

jaegerx
Sep 10, 2012

Maybe this post will get me on your ignore list!


Grump posted:

I'm completely lost in regards to running a cron job in crontab to auto renew my SSL. I'm currently running this command

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && ./path/to/certbot-auto renew

and I can see that it's run in the cron logs, but I don't have any mail server set up, so I can't see if there's any errors. Is there some way to easily email myself the logs in the command line without having a mail server set up?

Try typing mail when you’re root. It probably went to a mbox on your server.

mystes
May 31, 2006

Hot take: if you're connecting to a remote server and then always immediately sudoing I personally fail to see how that's particularly more secure than just directly logging in as root.

It feels sort of like how curl | bash is somehow inexplicably considered worse than downloading a random binary and running it without verifying it in any way.

G-Prime
Apr 30, 2003

Baby, when it's love,
if it's not rough it isn't fun.
The immediate advantage I can see to SSH in then sudo rather than SSH in as root is that you could do pubkey auth to SSH in and then require a password to sudo, as means of doing MFA root access. Though, at that point I don't really know why you wouldn't just use PAM's OTP support for it.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

mystes posted:

Hot take: if you're connecting to a remote server and then always immediately sudoing I personally fail to see how that's particularly more secure than just directly logging in as root.
Slightly better auditing of who logged in when

xzzy
Mar 5, 2009

Use Kerberos, the principal and account accessed get put in system logs.

For even more auditing look up HISTTIMEFORMAT.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

jaegerx posted:

Try typing mail when you’re root. It probably went to a mbox on your server.

I changed the MAILTO to my personal email. But if I don't have a mail server set up, this won't function at all, correct?

e: I was thinking about logging to a file and then deleting that file once a month for the time being until I get mailing capabilities. Looks like all my crons are functioning correctly

teen phone cutie fucked around with this message at 15:55 on May 12, 2018

evol262
Nov 30, 2010
#!/usr/bin/perl

mystes posted:

Hot take: if you're connecting to a remote server and then always immediately sudoing I personally fail to see how that's particularly more secure than just directly logging in as root.

It feels sort of like how curl | bash is somehow inexplicably considered worse than downloading a random binary and running it without verifying it in any way.

Spicy. But auditing and ssh keys are the right answer to protect from drive bys, along with not sharing the password, easy changes by adding/removing LDAP users to a group authorized to sudo, configuration management control of sudoers rules, etc. This is the same reason many businesses use powerbroker or other audit tools.

curl | bash is garbage because you have no idea what that script is doing unless you actually look at it, and GitHub (until very recently) allowed ghosting of popular projects. Grabbing a binary/rpm from sourceforge isn't necessary safer, but at least you can checksum that and match against a known checksum before you install it with Ansible or whatever

crazypenguin
Mar 9, 2005
nothing witty here, move along

Grump posted:

I was thinking about logging to a file

Just a handy tip, bash scripts can redirect themselves:

code:
#!/bin/bash

exec >> /path/to/log/file 2>&1

...

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Okay cool got that working.

My last big task to complete is figuring out email. On my site, I have a mail form that previously just used php’s mail() function, but with this new box I don’t have a mail server set up. I was looking into PHPMailer as an alternative, but is getting a mail server up a must?

nem
Jan 4, 2003

panel.dev
apnscp: cPanel evolved
Postfix + nexthop sender transport to a service that uses SMTP authentication.

Disable “mynetworks” from smtpd_auth_restrictions to provide some audit trail either through the local pickup service or SASL authentication for mail that originates from the server.

Edit: formatting... phone, rotting in a Dillard’s. Save me

Late edit: and use iptables to restrict SMTP access to postfix uid/mail gid.

nem fucked around with this message at 23:26 on May 12, 2018

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

nem posted:

Postfix + nexthop sender transport to a service that uses SMTP authentication.

Disable “mynetworks” from smtpd_auth_restrictions to provide some audit trail either through the local pickup service or SASL authentication for mail that originates from the server.

Edit: formatting... phone, rotting in a Dillard’s. Save me

Late edit: and use iptables to restrict SMTP access to postfix uid/mail gid.

e: loving BBCode is automatically formatting my links.

I ended up trying to install Postfix with Dovecot, but I hosed everything up and now somehow https://www.mysite.com and mysite.com have two different document roots, so I uninstalled all the mail server stuff I set up and I'm still having this issue. I have https://www. going to var/www/html/mysite.com/public_html and mysite.com going to var/html

My httpd config file looks like this

code:
# domain: mysite.com
# public: /var/www/html/mysite.com/public_html/

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin [email]webmaster@mysite.com[/email]
  ServerName [url]www.mysite.com[/url]
  ServerAlias mysite.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/mysite.com/public_html
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/mysite.com/log/error.log
  CustomLog /var/www/html/mysite.com/log/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mysite.com [OR]
RewriteCond %{SERVER_NAME} =mysite.com
RewriteRule ^ [url]https://%[/url]{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
The tutorial I was using told me to add an MX record of mysite.com with a higher priority than mail.mysite.com? Could that be the issue?

teen phone cutie fucked around with this message at 23:52 on May 13, 2018

Hughmoris
Apr 21, 2007
Let's go to the abyss!
I'll preface this with saying I'm a Linux novice:

I installed 18.04 on a virtualbox. When trying to use apt-get to install some packages, I'm being informed that it can't be installed because I'm missing python. Now I'm guessing that is because python3 is now the default for 18.04.

I'm unsure on how to go about safely fixing this so I can install packages that depend on python2.

anthonypants
May 6, 2007

by Nyc_Tattoo
Dinosaur Gum

Hughmoris posted:

I'll preface this with saying I'm a Linux novice:

I installed 18.04 on a virtualbox. When trying to use apt-get to install some packages, I'm being informed that it can't be installed because I'm missing python. Now I'm guessing that is because python3 is now the default for 18.04.

I'm unsure on how to go about safely fixing this so I can install packages that depend on python2.
Can you post the whole error message?

Hughmoris
Apr 21, 2007
Let's go to the abyss!

anthonypants posted:

Can you post the whole error message?

Here is what I get when I try: sudo apt-get install atom
code:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
atom is already the newest version (1.26.1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 atom : Depends: gconf2
        Depends: gconf-service
        Depends: python but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

SoftNum
Mar 31, 2011

Did you try what it suggested? (apt --fix-broken install)? a very short google session suggests it's likely some broken dependencies on your end. are you masking packages or anything?

Hughmoris
Apr 21, 2007
Let's go to the abyss!
I just tried the --fix-broken install, and it appears to have worked. Not masking any dependencies that I know of (not sure I would know if I was), just a clean install of 18.04.

Thanks for the help.

nem
Jan 4, 2003

panel.dev
apnscp: cPanel evolved

Grump posted:

httpd.conf
Edit: automatically parse URLs :downs:

I hate tutorials, because they explain what to do not why you do it. DO's incentivization structure to exchange tutorials for hosting credit is creating an absolute mess by diminishing the role of system administrator resulting in half-rear end setups such as what they're recommending.

It's broken because of virtualhost resolution. Apache will match a hostname:port to its corresponding virtualhost container. With this configuration both mysite.com:80 and www.mysite.com:80 will serve content from /var/www/html/mysite.com. Because you don't have a separate virtualhost container setup for *:443 with both mysite.com and www.mysite.com as a ServerAlias, it'll default to your system DocumentRoot setting in httpd.conf that is outside any <virtualhost>...</virtualhost> container. Setup a another virtualhost container, use the same config, add SSLEngine On, setup your SSL* directives, and that should do it.

Utilizing a nested document root structure is considered bad practice too. If foobar.com serves from /var/www/html, then you can unintentionally leak mysite.com by accessing foobar.com/mysite.com/whatever. Put your subordinate domains under /var/www/<domain> and your primary under /var/www/html. Plus it causes problems with htaccess rule inheritance as mysite.com under /var/www/html/mysite.com will check for and inherit any directives in /var/www/html assuming AllowOverride is set for /var/www.

quote:

The tutorial I was using told me to add an MX record of mysite.com with a higher priority than mail.mysite.com? Could that be the issue?
No, MX records are used solely in determining where to send mail for user@domain.com. domain.com has a MX record is that signifies the next hop for mail delivery. There's no reason to have an MX for both mysite.com and mail.mysite.com nor could you add an MX named mysite.com for mysite.com. That'd create a routing loop.

nem fucked around with this message at 21:06 on May 14, 2018

Autoexec.bat
Dec 29, 2012

Just one more level
So I have a bunch of PCs that are old enough to drink in the US and I'd like to throw some Linux on them for some basic internet functionality because I can and I'm a masochist (Ask me about my 80's Chrysler). I do know a moderate amount of Linux already so I can deal with installing packages and editing configs. Does anyone know any current distros that would run smoothly on the below (UI preferred):

-CPUs ranging between 120Mhz Cyrix 5x86 and 650mhz AMD Athlon, there are 2 400mhz dual PIIs too.
-Ram ranging from 128mb to 512mb at 33-100mhz.
-Hard drives from 1.5-40GB. Some have the 2GB bios limit
-Video cards range from a Trident SVGA to S3 Virge to a NVidia Geforce 420MX. Lots of ATI rage cards on hand.
-Sound cards are all either actual Sound Blaster 16s or compatible.
-Iso preferably small enough to burn onto a CD. USB booting is possible for those that have USB but it requires a floppy disk.
-All systems have at least a 10mb NIC.
-Chipsets are either VIA or stuff like the 440BX that is commonly emulated in VMs.

As for why I don't just buy a raspberry pi, well I own these and have the monitors/kb/mice etc and none of it would even connect to a PI since it's all like PS2/AT/Serial/VGA etc.

A few of them can run windows 7 poorly so don't let me down goons.

SoftNum
Mar 31, 2011

Debian at least still has an up to date i386 installation distributed on CD. That should get you basic X windows and a place to start. even when your hardware was current linux support was kind of the wild wild west so depending on graphics card and such there may be many hours of research involved in making everything work.

EDIT: Comedy answer: Setup external compilation for gentoo on your other systems and compile everything from scratch.

SoftNum fucked around with this message at 01:52 on May 15, 2018

evol262
Nov 30, 2010
#!/usr/bin/perl
I'd use BSD 10 times out of 10 on those

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

nem posted:

Edit: automatically parse URLs :downs:

I hate tutorials, because they explain what to do not why you do it. DO's incentivization structure to exchange tutorials for hosting credit is creating an absolute mess by diminishing the role of system administrator resulting in half-rear end setups such as what they're recommending.

It's broken because of virtualhost resolution. Apache will match a hostname:port to its corresponding virtualhost container. With this configuration both mysite.com:80 and https://www.mysite.com:80 will serve content from /var/www/html/mysite.com. Because you don't have a separate virtualhost container setup for *:443 with both mysite.com and https://www.mysite.com as a ServerAlias, it'll default to your system DocumentRoot setting in httpd.conf that is outside any <virtualhost>...</virtualhost> container. Setup a another virtualhost container, use the same config, add SSLEngine On, setup your SSL* directives, and that should do it.

Utilizing a nested document root structure is considered bad practice too. If foobar.com serves from /var/www/html, then you can unintentionally leak mysite.com by accessing foobar.com/mysite.com/whatever. Put your subordinate domains under /var/www/<domain> and your primary under /var/www/html. Plus it causes problems with htaccess rule inheritance as mysite.com under /var/www/html/mysite.com will check for and inherit any directives in /var/www/html assuming AllowOverride is set for /var/www.

No, MX records are used solely in determining where to send mail for user@domain.com. domain.com has a MX record is that signifies the next hop for mail delivery. There's no reason to have an MX for both mysite.com and mail.mysite.com nor could you add an MX named mysite.com for mysite.com. That'd create a routing loop.

That's odd that the Let's Encrypt tutorial never mentioned this at all. I had no idea HTTPS listens on a different port - I'm an absolute Linux noob

other people
Jun 27, 2004
Associate Christ
HTTPS using a different port is an HTTPS thing, not a linux thing.

kujeger
Feb 19, 2004

OH YES HA HA
HTTP and HTTPS are (by default anyway) set to be ports 80 and 443, respectively.

That's not to say it's impossible to run HTTPS over port 80. But you'd be in for a world of hurt as every browser that tried visting your page would try HTTP when visiting, while you'd be serving HTTPS.

Truga
May 4, 2014
Lipstick Apathy
home come starttls didn't get tacked on for http like it did for other protocols anyway?

xzzy
Mar 5, 2009

The fun part about port 80 is it serves no purpose anymore but handing out a permanent redirect to 443.

It should be a single line option in httpd.conf at this point.

nem
Jan 4, 2003

panel.dev
apnscp: cPanel evolved

Grump posted:

I'm an absolute Linux noob

Everyone is at one point. Best advice I can give you is pick up a book on Apache and read cover to cover. It provides the foundation of many critical RFCs that provide opportunities to learn further. Compile a kernel from source and learn too what the options under Processor features/General setup do at a bare minimum.

You can use tutorials as a starting point, but buy a book to flesh out your knowledge unless you want your server to runaway and join the Syrian Liberation Army or Palestinian cause or Free Tibet or #notmypresident or whatever the fun ephemeral internet casus belli is this week. Tutorials only provide for shallow learning and on that level it’s not worth learning at all. The rest of what folks say around here is because we’ve got a killer porcelain tan and that takes many years of practical experience.

xzzy
Mar 5, 2009

Books are kinda questionable when you can google literally every administrative task you would ever need for a linux machine.

If that's your preferred type of learning not trying to talk anyone out of it, but it's not the One True Way(tm) to become competent.

nem
Jan 4, 2003

panel.dev
apnscp: cPanel evolved
Technical books are the only book format that don’t put me to sleep :(

As long as the material is comprehensive you can use it. Just not tutorials. Red hat publishes some great, thorough documentation.

Super-NintendoUser
Jan 16, 2004

COWABUNGERDER COMPADRES
Soiled Meat

nem posted:

Everyone is at one point. Best advice I can give you is pick up a book on Apache and read cover to cover. It provides the foundation of many critical RFCs that provide opportunities to learn further. Compile a kernel from source and learn too what the options under Processor features/General setup do at a bare minimum.

You can use tutorials as a starting point, but buy a book to flesh out your knowledge unless you want your server to runaway and join the Syrian Liberation Army or Palestinian cause or Free Tibet or #notmypresident or whatever the fun ephemeral internet casus belli is this week. Tutorials only provide for shallow learning and on that level it’s not worth learning at all. The rest of what folks say around here is because we’ve got a killer porcelain tan and that takes many years of practical experience.

I recommend that for people get familiar with linux is that they get ahold of an old laptop and install Fedora on it. Then get everything (I mean everything) to work, this includes:

1) media keys
2) hibernating/sleep function and buttons properly
3) wifi
4) wifi on/off switches
5) all function keys
6) screen dimming
7) webcam
8) closing lid making it properly go to sleep or hibernate or both

And then use it as your daily laptop. If you need a Windows app for work or a VPN, get that to work. For Windows setup WINE or a Windows VM. If something doesn't work, figure it out. And just do it.

You'll learn the ins and outs of dealing with the interesting problems of linux.

Now, the next few posts (as commonly occurs when I post this) will be responses that most of those things work out of the box with linux now, but I promise you it will be a frustrating adventure into madness to get it all working right to the point where you can start using the laptop 100%. If you want to learn Linux you have to use it for real, and this is a real darn good way to start.

Adbot
ADBOT LOVES YOU

kujeger
Feb 19, 2004

OH YES HA HA
Should also add "Docking" to that list (if applicable). On my current laptop everything on that list worked 100% out of the box. But not the tunderbolt-dock. That needed BIOS-configuring.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply