Posted in Server things

Slow Putty? Prevent reverse DNS lookups

Hint from securebadshah on superuser.com here

Probably the reverse DNS resolution (server trying to get client’s name given IP) is taking time. Can you check if /etc/ssh/sshd_config has setting “VerifyReverseMapping yes” ? Set it to “VerifyReverseMapping no” and check if helps.

Edit: It seems VerifyReverseMapping is now deprecated and useDNS is the new configuration in the sshd_config.

Adding a “useDNS no” line to /etc/ssh/sshd_config made my ssh login via Putty happen much faster.

Posted in Server things

Postfix and setting up email accounts

Prerequisite knowledge for configuring settings described in this post:
Postfix configuration parameters are controlled via the main.cf file, located at /var/postfix/main.cf

Postfix differentiates between three different sorts of domains:

  • Local users (normal system users, as listed in the /etc/passwd file): It’s not possible to make local users work in just one domain. They will rather receive (and save under /var/mail/USERNAME) email sent to any and all local domains, ie all domains in the mydestination configuration setting. (The mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine. eg mydestination = example.org, example.com, example.net) Takeaway message: All system users will get emails send to their_username@ any local domain.
  • Virtual mailbox domains/virtual users:  These are also domains you specify in your Postfix configuration settings as ones that will be used to receive email (in this case using the virtual_mailbox_domains = example.org example.com), but rather than using system users (/etc/passwd) to specify valid email addresses in that domain, you explicitly tell Postfix in its config settings which addresses are valid in a domain. You then specify similarly which emails we are ready to receive emails for and where they’ll be stored on the disk.
  • Virtual alias domains: These are used to forward email from one email address to another. They can’t receive email, only forward it to somewhere else, or to several someplace elses.

If you have very few domains, the domains can be specified directly in the config file and the emails in a text file. See here for more info, but basically the text file is a mapping file, that is, it contains two columns.

 

For larger setups, these textfiles can be configured with information on how to connect to the same two columns’ worth of data as stored in your MySQL server instead.

After you’ve finished specifying your configurations, you need to run the postmap tool on the files to compile them.

Adding users

Assuming a properly configured setup, users can be entered at the SQL command line like so:

INSERT INTO `mail`.`users` (`email`, `password`, `quota`) VALUES ('sales@example.com', ENCRYPT('secret'), 1073741824);

The folder structure for any given email address isn’t set up until an email is received at that address, so shoot a test email through before checking to see if you can log in via your SquirrelMail or other webmail.

If you find you can’t log in, and want to check whether the email’s been received, you can search the logs for instances of your new email address:

vim /var/log/mail.log

To move to the end of the log file (where your activity will be, unless you slipped into a decent sleep after dispatching your test email):

Shift+g

To search the file you need to type a / then the words you want to search on:

/sales@example.com

Press ‘esc’ to cancel out of searching, (little) ‘n’ to jump forward through the instances of your search term that were found in the log, and (capital) ‘N’ to search backwards.

If the only thing you’re finding is failed login attempts and no record of your test email having been received, keep a-waiting, all’s probably well and the test email just hasn’t arrived yet. When it does you’ll be able to log in successfully.

Resources Referred To:

Posted in Server things

Life-saving (well, time-saving) stuff working with Rmagick

I just installed Imagemagick on the Mac as a prerequisite for installing the Rmagick gem for image processing with CarrierWave.

After performing the necessaries to get CarrierWave using Rmagick, the server crashed, then crashed again when I tried a second time.

Here’s the solution:

brew install imagemagick --disable-openmp

If you’ve already got imagemagick installed, it will need to be uninstalled before reinstallation with that option. That can be done all in one step as follows:

brew uninstall imagemagick && brew install imagemagick --disable-openmp

The Rmagick gem also then needs to be rebuilt against the new Imagemagick installation:

gem pristine rmagick 

Via stackoverflow here.

Posted in Server things

Finding and killing processes using the terminal in OSX

I just accidentally closed my terminal window and had reason to figure out how to kill the processes I had open in terminal tabs so that I can continue to restart and reconfigure them as I work.

ps ax | grep mysqld

will return any processes, including possible the grep itself.

sudo kill [mysqld process number]

shuts that baby off. (You’ll be prompted for the admin password, obvs.)

ps ax | grep mysqld

again to make sure it’s worked.

What are these commands? –from The Unix Command Line (System Administration Commands)

ps : list the processes running on the system

ps : (on its own) list processes owned by current user and that are currently attached to the terminal

ps -x : list processes belonging to the current user whether or not they’re attached to a terminal

ps -ax : list all processes running on the system

ps -aux : list all processes running on the system along with additional information about their resource usage