Close Menu
    Facebook X (Twitter) Instagram
    • Download Cisco Packet Tracer
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Server
    • WordPress
    IT Beginner
    Home»Linux Mint»How to install, config and secure openssh server
    Linux Mint

    How to install, config and secure openssh server

    18/07/2017Updated:18/07/2017No Comments4 Mins Read

    OpenSSH provides end-to-end encrypted replacement of applications such as telnet, rlogin, and ftp. Unlike these legacy applications, OpenSSH never passes anything (including username and password) over the wire in unencrypted form, and provides host authentication, to verify that you really are talking to the system that you think you are and that no one else can take over that session. Currently OpenSSH can be used with OpenBSD, NetBSD, FreeBSD, AIX, HP-UX, IRIX, Linux, NeXT, SCO, SNI/Reliant Unix, Solaris, Digital Unix/Tru64/OSF, Mac OS X, Cygwin.

    Install OpenSSH
    You will want your system can both receive and make connections via OpenSSH, so you will need to install server and client packages

    For Ubuntu, Mint, or Debian based distributions

    # apt-get install openssh openssh-server openssh-clients

    For Fedora, Centos, or Red Hat based distributions

    # yum install openssh openssh-server openssh-clients


    Config and Secure OpenSSH

    Default openssh config files
    /etc/ssh/sshd_config – OpenSSH server configuration file.
    /etc/ssh/ssh_config – OpenSSH client configuration file.

    Default openssh port
    TCP 22

    There are a few tweaks and changes before you open up your ssh server to connections from the outside world.

    1. Disable OpenSSH server
    You should disable and remove openssh on machines that you don’t need connections to, like workstation, laptop

    For Ubuntu, Mint, or Debian based distributions

    # apt-get remove openssh-server

    For Fedora, Centos, or Red Hat based distributions

    # chkconfig sshd off
    # yum erase openssh-server

    You will need to update and restart your iptables if you have one to remove ssh exception rule.

    # nano /etc/sysconfig/iptables

    2. Only Use SSH Protocol 2
    Make sure its in your openssh server config file

    Protocol 2

    3. Limit access to ssh server
    Only allow certain user/users to access your ssh server and deny user/users you don’t want to access to ssh server.

    To allow user/users, add this to sshd_config

    AllowUsers tom marry mike

    To deny

    DenyUsers root jenny

    Personally i highly suggest you deny root user on ssh server and ssh with normal unprivileged user, then you can become root after that.

    To become root you can use su command

    For Ubuntu, Mint, or Debian based distributions

    $ sudo su

    For Fedora, Centos, or Red Hat based distributions

    $su -

    # Config Idle Log Out Timeout Interval
    You would not want to leave your ssh session unattended, having idle log out timeout is a good idea to do so. Here i set mine at 300 seconds or 5 minutes

    ClientAliveInterval 300
    ClientAliveCountMax 0

    4. Disable .rhosts Files

    IgnoreRhosts yes

    6. Disable Host-Based Authentication
    HostbasedAuthentication no

    7. Disable root Login via SSH
    As I mentioned before, you dont want to login with your root account. Besind deny user root, you should also disallow it.

    PermitRootLogin no

    8. Having a Warning Banner
    This is not really effective to against somebody want to break in your ssh server, but it’s cool to have one and sort of legal warning.

    Banner /etc/ssh_banner

    Sample warning banner /etc/ssh_banner

    ************************************************

    NOTICE TO USERS WARNING!
    The use of this system is restricted to authorized users, unauthorized access is forbidden and will be prosecuted by law. All information and communications on this system are subject to review, monitoring and recording at any time, without notice or permission. Users should have no expectation of privacy.

    *************************************************

    8. Change SSH server port
    After **deny and disallow root login** at number 3. and 7., I belive changing ssh server port to a non-standard port is the **second most important** effective way to prevent break in ssh server. I **belive** (I might be wrong) anything between port 1024 to 65535 is safe to use.

    Port 10000

    9. Disable Empty Passwords
    You don’t want anyone to login to your ssh server with an empty password

    PermitEmptyPasswords no
    openssh ssh server
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to upgrade fedora 19 to 20
    Next Article How to setup a LAMP server Linux, Apache, MySQL, PHP on Centos 6 VPS

    Related Posts

    Tips – Tricks

    How to fix nginx an upstream response is buffered to a temporary file error

    05/08/2017
    Tips – Tricks

    Optimize WordPress with Nginx

    04/08/2017
    Security

    How to secure Nginx web server

    02/08/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    Tags
    apache centos Centos 6 cuda Desktop Environment dual boot environment featured gnome GUI hostname hosts intel kernel kill lamp server lemp server life MariaDB netflix nginx nvidia password php-fpm phpmyadmin pids processes s.m.a.r.t Security session solid state drive ssd ssh ssh server tag 1 tag 2 Ubuntu upgrade varnish VirtualBox VNC Server web server window manager wordpress xfce
    Facebook X (Twitter) Instagram Pinterest

    Type above and press Enter to search. Press Esc to cancel.

    wpDiscuz