<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.docking.org/index.php?action=history&amp;feed=atom&amp;title=Configuring_an_OpenSSH_Server</id>
	<title>Configuring an OpenSSH Server - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.docking.org/index.php?action=history&amp;feed=atom&amp;title=Configuring_an_OpenSSH_Server"/>
	<link rel="alternate" type="text/html" href="http://wiki.docking.org/index.php?title=Configuring_an_OpenSSH_Server&amp;action=history"/>
	<updated>2026-05-24T19:34:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://wiki.docking.org/index.php?title=Configuring_an_OpenSSH_Server&amp;diff=9430&amp;oldid=prev</id>
		<title>Benrwong: Created new page containing Lab Manual content regarding OpenSSH server configuration</title>
		<link rel="alternate" type="text/html" href="http://wiki.docking.org/index.php?title=Configuring_an_OpenSSH_Server&amp;diff=9430&amp;oldid=prev"/>
		<updated>2016-06-27T22:05:37Z</updated>

		<summary type="html">&lt;p&gt;Created new page containing Lab Manual content regarding OpenSSH server configuration&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Configuring an OpenSSH server Using Centos 6.4=&lt;br /&gt;
Install a minimal Centos iso on the server.&lt;br /&gt;
The following needs to be installed: openssh logwatch fail2ban semanage sendmail&lt;br /&gt;
Openssh, logwatch and sendmail are easy to install:&lt;br /&gt;
 yum -y install openssh sendmail&lt;br /&gt;
For selinux/semanage:&lt;br /&gt;
 yum whatprovides /usr/sbin/semanage&lt;br /&gt;
 yum -y install policycoreutils-python…….&lt;br /&gt;
 semanage port -a -t ssh_port_t -p tcp 62&lt;br /&gt;
 semanage port -l | grep ssh  #To make sure ssh is running on port 62&lt;br /&gt;
For fail2ban install and configuration go to page &lt;br /&gt;
For logwatch install and configuration go to page&lt;br /&gt;
 useradd you&lt;br /&gt;
 passwd  you &lt;br /&gt;
Generate ssh keys for yourself and test them before proceeding.&lt;br /&gt;
For ssh key generation go to page &lt;br /&gt;
 vim /etc/ssh/sshd_config&lt;br /&gt;
&lt;br /&gt;
The following is what the sshd_config file should look like, change it accordingly.  I bolded the parts that aren’t commented for easier reading:    &lt;br /&gt;
 #       $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $&lt;br /&gt;
 # This is the sshd server system-wide configuration file.  See&lt;br /&gt;
 # sshd_config(5) for more information.&lt;br /&gt;
 # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin&lt;br /&gt;
 # The strategy used for options in the default sshd_config shipped with&lt;br /&gt;
 # OpenSSH is to specify options with their default value where&lt;br /&gt;
 # possible, but leave them commented.  Uncommented options change a&lt;br /&gt;
 # default value.&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Port 62&lt;br /&gt;
 AddressFamily inet&amp;#039;&amp;#039;&amp;#039;        &lt;br /&gt;
 #ListenAddress 0.0.0.0&lt;br /&gt;
 #ListenAddress ::&lt;br /&gt;
 # Disable legacy (protocol version 1) support in the server for new&lt;br /&gt;
 # installations. In future the default will change to require explicit&lt;br /&gt;
 # activation of protocol 1&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Protocol 2&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 # HostKey for protocol version 1&lt;br /&gt;
 #HostKey /etc/ssh/ssh_host_key&lt;br /&gt;
 # HostKeys for protocol version 2&lt;br /&gt;
 #HostKey /etc/ssh/ssh_host_rsa_key&lt;br /&gt;
 #HostKey /etc/ssh/ssh_host_dsa_key&lt;br /&gt;
 # Lifetime and size of ephemeral version 1 server key&lt;br /&gt;
 #KeyRegenerationInterval 1h&lt;br /&gt;
 #ServerKeyBits 1024&lt;br /&gt;
 # Logging&lt;br /&gt;
 # obsoletes QuietMode and FascistLogging&lt;br /&gt;
 #SyslogFacility AUTH&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;SyslogFacility AUTHPRIV&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #LogLevel INFO&lt;br /&gt;
 # Authentication:&lt;br /&gt;
 #LoginGraceTime 2m&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;PermitRootLogin no&lt;br /&gt;
 StrictModes yes&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #MaxAuthTries 6&lt;br /&gt;
 #MaxSessions 10 &lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;RSAAuthentication yes&lt;br /&gt;
 PubkeyAuthentication yes&lt;br /&gt;
 AuthorizedKeysFile %h/.ssh/authorized_keys&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #AuthorizedKeysCommand none&lt;br /&gt;
 #AuthorizedKeysCommandRunAs nobody&lt;br /&gt;
 # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts&lt;br /&gt;
 # RhostsRSAAuthentication no&lt;br /&gt;
 # similar for protocol version 2&lt;br /&gt;
 #HostbasedAuthentication no&lt;br /&gt;
 # Change to yes if you don&amp;#039;t trust ~/.ssh/known_hosts for&lt;br /&gt;
 # RhostsRSAAuthentication and HostbasedAuthentication&lt;br /&gt;
 #IgnoreUserKnownHosts no&lt;br /&gt;
 # Don&amp;#039;t read the user&amp;#039;s ~/.rhosts and ~/.shosts files&lt;br /&gt;
 # Don&amp;#039;t read the user&amp;#039;s ~/.rhosts and ~/.shosts files&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;IgnoreRhosts yes&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 # To disable tunneled clear text passwords, change to no here!&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;PasswordAuthentication no&lt;br /&gt;
 PermitEmptyPasswords no&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #PasswordAuthentication yes&lt;br /&gt;
 # Change to no to disable s/key passwords&lt;br /&gt;
 #ChallengeResponseAuthentication yes&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;ChallengeResponseAuthentication no &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 # Kerberos options&lt;br /&gt;
 #KerberosAuthentication no&lt;br /&gt;
 #KerberosOrLocalPasswd yes&lt;br /&gt;
 #KerberosTicketCleanup yes&lt;br /&gt;
 #KerberosGetAFSToken no&lt;br /&gt;
 #KerberosUseKuserok yes&lt;br /&gt;
 # GSSAPI options&lt;br /&gt;
 #GSSAPIAuthentication no&lt;br /&gt;
 #GSSAPIAuthentication yes&lt;br /&gt;
 #GSSAPICleanupCredentials yes&lt;br /&gt;
 #GSSAPICleanupCredentials yes&lt;br /&gt;
 #GSSAPIStrictAcceptorCheck yes&lt;br /&gt;
 #GSSAPIKeyExchange no &lt;br /&gt;
 # Set this to &amp;#039;yes&amp;#039; to enable PAM authentication, account processing, &lt;br /&gt;
 # and session processing. If this is enabled, PAM authentication will &lt;br /&gt;
 # be allowed through the ChallengeResponseAuthentication and&lt;br /&gt;
 # PasswordAuthentication.  Depending on your PAM configuration,&lt;br /&gt;
 # PAM authentication via ChallengeResponseAuthentication may bypass&lt;br /&gt;
 # the setting of &amp;quot;PermitRootLogin without-password&amp;quot;.&lt;br /&gt;
 # If you just want the PAM account and session checks to run without&lt;br /&gt;
 # PAM authentication, then enable this but set PasswordAuthentication&lt;br /&gt;
 # and ChallengeResponseAuthentication to &amp;#039;no&amp;#039;.&lt;br /&gt;
 #UsePAM no&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;UsePAM yes&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 # Accept locale-related environment variables&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES&lt;br /&gt;
 AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT&lt;br /&gt;
 AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE&lt;br /&gt;
 AcceptEnv XMODIFIERS&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #AllowAgentForwarding yes&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;AllowTcpForwarding yes&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #GatewayPorts no&lt;br /&gt;
 #X11Forwarding no&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;X11Forwarding yes&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #X11DisplayOffset 10&lt;br /&gt;
 #X11UseLocalhost yes&lt;br /&gt;
 #PrintMotd yes&lt;br /&gt;
 #PrintLastLog yes&lt;br /&gt;
 #TCPKeepAlive yes&lt;br /&gt;
 #UseLogin no&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;UsePrivilegeSeparation yes&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #PermitUserEnvironment no&lt;br /&gt;
 #Compression delayed&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;ClientAliveInterval 300&lt;br /&gt;
 ClientAliveCountMax 0&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 #ShowPatchLevel no&lt;br /&gt;
 #UseDNS yes&lt;br /&gt;
 #PidFile /var/run/sshd.pid&lt;br /&gt;
 #MaxStartups 10:30:100&lt;br /&gt;
 #PermitTunnel no&lt;br /&gt;
 #ChrootDirectory noned&lt;br /&gt;
 # no default banner path&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Banner /etc/ssh/banner_message&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 # override default of no subsystems&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;Subsystem       sftp    /usr/libexec/openssh/sftp-server&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 # Example of overriding settings on a per-user basis&lt;br /&gt;
 #Match User anoncvs&lt;br /&gt;
 #       X11Forwarding no&lt;br /&gt;
 #       AllowTcpForwarding no&lt;br /&gt;
 #       ForceCommand cvs server&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;AllowUsers tdemers&lt;br /&gt;
 HostBasedAuthentication no&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 service sshd restart&lt;br /&gt;
&lt;br /&gt;
Then, you&amp;#039;re done!&lt;br /&gt;
&lt;br /&gt;
Some notes on the rationale behind the way I configure the sshd_config file:&lt;br /&gt;
I set the ClientAliveInterval to 300 (seconds, or 5 minutes) because this machine is used as a portal.  There should be no work or anything else done on this machine by any user; 5 minutes is an ample amount of time to ssh into the cluster.  &lt;br /&gt;
The ClientAliveCountMax variable specifies the number of sshd messages that will be sent without receiving any messages back from the client.  I set this to 0 because I did not think that this was a necessary thing to enable.&lt;br /&gt;
I set the IgnoreRhosts to yes because this disables the .rhosts and .shosts files; disables a potential backdoor.&lt;br /&gt;
The Banner variable specifies where the file is that contains the message you want to have printed when a user attempts to access the server.  I set Banner to the file /etc/ssh/banner_message.  In this file (that I created) it contains: &lt;br /&gt;
If you are experiencing problems accessing this server please send an email to: access.bkslab@gmail.com&lt;br /&gt;
&lt;br /&gt;
Feel free to change this message to whatever you feel is appropriate.&lt;br /&gt;
&lt;br /&gt;
Some other notes:&lt;br /&gt;
In the sshd_config file, AllowUsers trumps AllowGroups.  Also, if you have them both defined in the sshd_config file, the users in the AllowUsers line must also be part of the group specified in AllowGroups.&lt;br /&gt;
I decided to add a group and not specify specific users in the AllowUsers line because it was getting hard to maintain.  Here is what I did:&lt;br /&gt;
&lt;br /&gt;
 groupadd -r sshUsers   # I used the -r option because this is a system group&lt;br /&gt;
 usermod -a -G sshUsers username  #This adds the user to the sshUsers group&lt;br /&gt;
&lt;br /&gt;
Then I added in the sshd_config file the following line:&lt;br /&gt;
 AllowGroups sshUsers&lt;br /&gt;
and deleted the line:&lt;br /&gt;
 AllowUsers&lt;br /&gt;
&lt;br /&gt;
 restart sshd&lt;br /&gt;
&lt;br /&gt;
To remove a user from the group:&lt;br /&gt;
 gpasswd -d username sshUsers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To see a list of all the users in a group:&lt;br /&gt;
 cat /etc/group | grep sshUsers&lt;br /&gt;
&lt;br /&gt;
[[Category:Sysadmin]]&lt;/div&gt;</summary>
		<author><name>Benrwong</name></author>
	</entry>
</feed>