Original Document
Original Document
Original Document
Information tables**
This lab will use a Debian Virtual machine as the secure shell server and your host machine as the
client. Throughout this document, the terms host and client are used interchangeably to refer to a
terminal on your physical host machine. The first information table is to aid documenting the NTP
andSyslog setup, the second table is for the SSH setup.
Formula
Used in Lab
Debian VM
172.16.(n).10
DEBIAN_IP
Raspberry Pi
172.16.(n).20
PI_IP
CentOS VM
172.16.(n).50
CENTOS_IP
NTP Source
172.16.1.253
172.16.1.253
Answer
Used in Lab
DEBIAN_USER
DEBIAN_IP
Value
Lab
Before starting make sure that network configuration for eth0 and lo interfaces are valid.
Also, make sure your Linux has a valid DNS server configuration. Remember eth0 and
lo are typical names, they may vary on your systems.
NTP
Check the Labs NTP server
1.
2. Run ntpdate
/usr/sbin/ntpdate q 172.16.1.253
3. An example report from ntpdate is shown below. The stratum is highlighted in the report below.
9/14/2015 5:27:00 PM
Page 1 of 9
Edit /etc/ntp.conf
Allow servers on local subnet to query our server
Comment out all lines beginning with server
Add a new line for the Labs NTP source
# Allow clients on 127.16.1.0/24 to query this server
restrict 172.16.(n).0 mask 255.255.255.0 nomodify notrap
# Commented out these servers
#server 0.debian.pool.ntp.org
#server 1.debian.pool.ntp.org
#server 2.debian.pool.ntp.org
#server 3.debian.pool.ntp.org
# Added a line for the Labs NTP source
server 172.16.1.253
2.
a
3.
a
b
4.
a
5.
a
b
You should not configure the CentOS NTP daemon until the Debian NTP daemon has synchronized.
Edit /etc/ntp.conf
Comment out all lines beginning with server
Add a new line for your Debian VMs NTP source
# Commented out these servers
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
# Added a line for my Debian VMs NTP source
server DEBIAN_IP
3.
a
b
c
4.
a
b
9/14/2015 5:27:00 PM
Page 2 of 9
Syslog
Configuring Debian VM Syslog Daemon
1.
a.
b.
Debian uses rsyslogd, an enhanced replacement for the venerable syslog package. We will not be using all of its advanced
features for this lab.
Edit /etc/rsyslog.conf
Enable Logging of remote syslog messages
Send all log messages to a remote syslog server
# Uncommented the following lines. These enable
# Logging of incoming UDP messages from the network.
# This is normally achieved with the -r option to syslog
$ModLoad imudp
$UDPServerRun 514
Edit /etc/rsyslog.conf
Send all log messages to your Debian VM. Ensure the following is in the file.
# Transmit all logs to my Debian VM
*.* @@DEBIAN_IP
2.
a.
b.
3.
a.
b.
c.
d.
SSH
Installing Secure Shell
Note: Hopefully, you have used ssh server from both your Debian server VM and your CentOS client VM. In case you have
not completed the openssh server install:
To install the secure shell daemon on your server, you will use aptitude. As root on your Debian VM, execute:
# aptitude -R install openssh-server
This installs the daemon, generates server keys, and starts sshd automatically.
Determining Server IP Address
With your Debian VM, verify your IP address with the following command:
$ /sbin/ifconfig
Record this IP address in the Information table at the beginning of this document. You will need to use this IP address when
using SSH to log in to your server.
9/14/2015 5:27:00 PM
Page 3 of 9
Installing DenyHosts
DenyHosts monitors the secure log (/var/log/auth.log on Debian) for failed login attempts. Its configuration file is in
/etc/denyhosts.conf, but the default configuration is acceptable for our uses.
# aptitude R install denyhosts
This installs the daemon and starts denyhosts automatically.
Testing DenyHosts
DenyHosts has different policies depending on whether a failed attempt is for a non-existent account, a normal account, or
the root account. Access to the root account is the strictest and therefore the easiest to test.
Run the SSH command twice and simply hit enter at the password prompts.
$ ssh root@DEBIAN_IP
Wait a moment, as blocking IP addresses is not instantaneous and then try to log in again using SSH. You should see the
error below.
$ ssh root@DEBIAN_IP
ssh_exchange_identification: Connection closed by remote host
You can also see the blocked IP address in /etc/hosts.deny on the server.
Generating Keys
We will next create a public/private key pair so we can connect more securely. On your client, execute the following
command.
$ ssh-keygen -t rsa -b 4096
This step requests a password that will be used to encrypt your private key on disk. It is not essential to set a password, but
it adds an extra layer of security. For this lab, DO NOT enter a password here.
This command will create two keys: id_rsa and id_rsa.pub in ~/.ssh/.
9/14/2015 5:27:00 PM
Page 4 of 9
Modifying sshd_config
The configuration file for the SSH daemon is located in /etc/ssh/sshd_config on your server. We will be modifying lines
relating to authentication. Using your editor of choice you will need to locate and modify certain lines as follows:
# Make sure that we can authenticate using our public/private key pair
PubkeyAuthentication yes
# Disable logins using standard passwords
PasswordAuthentication no
You will need to restart sshd after your modifications to enable these changes. Execute:
# /etc/init.d/ssh restart
Questions
1.
2.
3.
4.
5.
6.
7.
8.
9.
9/14/2015 5:27:00 PM
Page 5 of 9
Deliverables
Information
Table 3
Description
Assigned Subnet Number:
Your Last Name:
Debian VM IP:
Raspbian Pi IP:
CentOS VM IP:
DNS Forwarder:
Subzone:
Formula
n
<last_name>
172.16.n.10
172.16.n.20
172.16.n.50
<last_name>.hades.lab
Used in Lab
DEBIAN_IP
PI_IP
CENTOS_IP
172.16.1.252
SUBZONE
Answer
172.16.1.252
If your last name is Jones, your SUBZONE would be jones.hades.lab. Use the last name as it appears (no uppercase
letters) on the IP subnet assignment page on Moodle. REMEMBER - as of this lab your DEBIAN_IP needs to end in 10.
The DNS glue records on the lab server have been set to point to 172.16.n.10. Any number other than 10 will not function
properly.
Load Debian VM
Verify the VMs IP Address matches the IP address you calculated in the Information section above
Refer to Lab 1 for information on viewing and modifying your IP address
9/14/2015 5:27:00 PM
Page 6 of 9
Edit /etc/bind/named.conf.local
Add a zone for your subzone you calculated in the Information section above
zone "SUBZONE" IN {
type master;
file "/var/cache/bind/db.SUBZONE";
allow-update { none; };
};
2.
a
b
c
d
3.
a
IN
CNAME
Debian
Figure 1. If you make any mistakes in this file, update the Serial before
Troubleshooting
9/14/2015 5:27:00 PM
Page 7 of 9
Stage 2: DNSSEC
1
a
Edit /etc/bind/named.conf.options
Enable DNSSEC
// Add this inside the options {} statement
dnssec-enable true;
2
a
b
3
a
b
i
c
4
a
b
c
Key Name
Zone Signing Key
Key Signing Key
5
a
6
a
7
a
b
Used in Lab
ZONE_SIGNING_KEY
KEY_SIGNING_KEY
File Name
Edit your zone file and $INCLUDE the two keys you noted in the table above
e.g. /var/cache/bind/db.SUBZONE
Remember to increment the zones serial number
; Append these two lines to your zone file.
$INCLUDE /etc/bind/keys/ZONE_SIGNING_KEY
Create a signed zone file
This step needs to be run from the /etc/bind/keys directory. It is all on one line.
dnssec-signzone r /dev/urandom -k KEY_SIGNING_KEY -o SUBZONE -t -A
/var/cache/bind/db.SUBZONE ZONE_SIGNING_KEY
Verify the zone file is signed correctly
named-checkzone SUBZONE /var/cache/bind/db.SUBZONE.signed
Should mention that the zone is signed
zone "SUBZONE" IN {
type master;
file "/var/cache/bind/db.SUBZONE.signed";
allow-update { none; };
};
Questions
1
Nowhere in this lab exercise did we modify the /etc/resolv.conf file to use the DNS server we created. Why does this
work?
9/14/2015 5:27:00 PM
Page 8 of 9
Can you look up a host name in your sub domain from your host workstation? Please explain your answer and why you
think it does or does not work.
E.g. does dig debian.SUBZONE work on your host workstation.
Why is using /dev/urandom in the real world a bad idea? The manual page for random will likely help with answering this
question. (man 4 random) Explain in your own words how this could be exploited in practice.
9/14/2015 5:27:00 PM
Page 9 of 9