Lead Image © Fotoflash,Fotolia.com

Lead Image © Fotoflash,Fotolia.com

The top three SSH tricks

Security Skills

Article from ADMIN 40/2017
By
Add extra security to your SSH service, securely copy files to and from remote computers, and configure passwordless SSH for automation scripting.

Secure Shell (SSH) is more than a simple remote connectivity protocol. The SSH utility is one of the most versatile tools in your administrative toolbox. You can use SSH to copy files securely, and you can even build it into automation scripts.

Trick 1: Configuring a More Secure SSH

Although SSH is secure in a default installation, you can make some tweaks to provide an even more secure environment. The parameters to change are located in /etc/ssh/sshd_config. The first security change is to deny root user logins by finding the line

PermitRootLogin Yes

and changing the Yes to No.

If you have a limited number of users (fewer than 10), you can use the AllowUsers entry to limit which users can use SSH to connect to the server. Remember to include yourself on the user list, which is space delimited:

AllowUsers bob admin fred joe

If you have more than 10 users or if you choose to manage by groups, create an sshusers or similar group and add users as needed:

$ sudo groupadd --r sshusers
$ sudo usermod --a --G sshusers bob

In sshd_config, use the AllowGroups directive with your group name,

AllowGroups sshusers

and restart the SSH daemon:

$ sudo service ssh restart

For systemd servers, use either of the following commands:

$ sudo systemctl restart sshd
$ sudo systemctl restart ssh

A final change to enhance SSH security on your network is to allow SSH sessions to originate only from a single server, often known as a "jump" server. This change is outside of the SSHD configuration and only involves limiting the allowed IP address through iptables by entering the command

$ sudo iptables -A INPUT -p tcp -s [IP
...
Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • SSH on Windows

    For Linux admins, SSH is one the most important tools of remote administration. SSH also works in Windows, with tools such as PuTTY or WinSSH, MobaXterm, WinSCP, or Swish.

  • MobaXterm: Unix for Windows

    MobaXterm, a portable X server for Windows, bundles built-in Unix/Posix tools into a single portable EXE file, letting you use a Linux command line and tools on the Windows desktop.

  • Sort out your SSH configs
    The scope and functionality of SSH and sFTP provides both secure remote access and secure file transfers.
  • Automation Scripting with PHP

    PHP is a powerful scripting language that has built-in database connectivity, simple syntax, one of the world’s largest support groups, and respect in enterprise scripting circles. When you have a scripting problem, PHP is good for what ails you.

  • Userspace secure filesystem
    SSHFS is often overlooked as an HPC shared filesystem solution.
comments powered by Disqus