SlideShare a Scribd company logo
CN8822
Assignment #2
2
Assignment 2 – Secure Remote administration and firewalls ________________________________ 3
Part1 _____________________________________________________________________________ 3
Objective: To Study the concepts of remotely administering a server using ssh.__________________ 3
Public-key authentication should be used for the root user __________________________________ 9
Part II-Objective: To study the concepts of ssh port forwarding._____________________________ 12
Part III -Objective: Firewall using IPTABLES ______________________________________________ 17
References ________________________________________________________________________ 21
CN8822
Assignment #2
3
Assignment 2 – Secure Remote administration and firewalls
Part1
Objective: To Study the concepts of remotely administering a server using ssh.
1)You are to secure a Linux server by restricting remote root access by running a separate sshd daemon.
Make the necessary changes to have the newly configured sshd daemon comply with following restrictions:
1. Daemon must start on all run levels, i.e. 2345
2. root should have remote access to this server using new sshd daemon and no others.
3. All others should be accessing the server using the existing sshd daemon; again root should not be to
access this sshd daemon.
4. Public-key authentication should be used for the root user
5. Feel free to add any configuration directives to further secure the ssh daemon
Explanation:
There is one SSH daemon runs by default to provide the ssh service on the default port 22. To have a
separate SSH daemon we need to have separate run level and configuration files, and to isolate both
daemons to work independently we copied binary file with different name .
This was achieved by following these steps.
1) Copy sshd binary file with new name sshd_root with the –p option to retain same rights.
2) Copy sshd_config file with new name and make necessary changes to have separate keys for
Root user and normal user, have separate pid file, separate port, separate Login Rules, these
Rules are highlighted in the file
CN8822
Assignment #2
4
Also have a separate PID file
CN8822
Assignment #2
5
Here is the changes which have made in the sshd_root config file and we have highlighted them.
CN8822
Assignment #2
6
3) Have separate init scripts for sshd daemon and sshd_root daemon, we have highlighted the
Changes in both files .
In the ssh script file we have pointed to correct config file
Also changed the pid file name to new pid file all the corresponding functions.
Similar changes were made in the ssh_root init script and we have highlighted them , most
important change was to point to new binary sshd_root in the /usr/bin directory.
Next change is point to right config file.
CN8822
Assignment #2
7
3rd change was to have separate pid file as shown
After all these changes we were able to successfully register the ssh_root as a separate daemon at
the specified runlevels which is 2345 by using debian service register tool
We can verify this by checking at the soft links at the rc startup level.
After All these changes we were able to start/stop these two daemon separately and verified the
login Rules.
Here is the screenprint of separate pid files.
CN8822
Assignment #2
8
We restarted the server and two daemons started independently.
We tried to login as root on port 22 it failed
Where as normal user login was successful.
Similarly root login was successful at port 2501 and normal user failed on this port.
CN8822
Assignment #2
9
Login as root was successful using port 2501 as shown.
From this we were able to confirm that our two ssh daemon are working as expected in our
Assignment.
Public-key authentication should be used for the root user
For the Public Key Authentication we used two machines with IP 192.168.56.101 as Server A
And 192.168.56.102 as Server B and we were able to login with password.
Here is the steps we had followed.
1) Create a key for root user
CN8822
Assignment #2
10
2) Copy key to 192.168.56.102 using ssh-copy which copied the key to authorized directoy and
Login to 192.168.56.102, login was successful without prompting for Password.
CN8822
Assignment #2
11
CN8822
Assignment #2
12
Part II-Objective: To study the concepts of ssh port forwarding.
SSH tunnels can be created in several ways using different kinds of port forwarding
mechanisms. Ports can be forwarded in three ways.
1) Local port forwarding
2) Remote port forwarding
3) Dynamic port forwarding
Port forwarding or port mapping is a name given to the combined technique of
1) translating the address and/or port number of a packet to a new destination
2) possibly accepting such packet(s) in a packet filter(firewall)
3 ) forwarding the packet according to the routing table.
To illustrate Port Forwarding Example we have used Local port Forwarding.
We have Two Servers A(192.168.56.101) and B (192.168.56.102) both have Apache running
One Machine has default Apache test Page which we will treat as Client and Second Machine has
Our Custom Page as shown below.
CN8822
Assignment #2
13
This Machine we will treat as Server with IP 192.168.56.101 and Client one IP is
192.168.56.102 and Apache Page is
We will use Local Port Forwarding on Client to Display the server Apache page
To achieve this we will use SSH Local forwarding.
CN8822
Assignment #2
14
SSH Local forwarding Syntax is
ssh -L <local-port-to-listen>:<remote-host>:<remote-port> <gateway>
In our case we have decided to use Local port 4500 to listen to remote server port 80 using Remote
server as gateway.
ssh –L 4500:192.168.56.101:80 root@192.168.56.101
Once we are logged into to Server 192.168.56.101, we will be listening port 80 traffic of this box to
192.168.56.102, 4500 port.
We can confirm this by netstat
CN8822
Assignment #2
15
192.168.56.102 port 4500 is opened as local host; we will access this from the box itself
CN8822
Assignment #2
16
This confirms our configuration of Local port forwarding.
CN8822
Assignment #2
17
Part III -Objective: Firewall using IPTABLES
Firewall implementation using iptables. You are to setup the
Appropriate iptables rules to accomplish the following:
1. Using the same VM running the newly configured sshd daemon From Part I; setup a default-deny
policy to drop all inbound Traffic.
2. Only allow inbound traffic to both sshd ports, port 22 for public Access and privileged port for
root access. Note: Privileged Port is something you choose in Part I when new daemon was
Configured.
3. Only allow a trusted network or net-block to access the privileged sshd port.
4. Log all other dropped packets
Explanations
Firewalls are used to block unauthorized access to Network. All Linux Flavors provide basic
firewall in the kernel “IPTABLES” which can be used to provide simple IPv4 and IPV6 packet
filtering and Network Address Translation.
IP Table provided three set of Rules, knows as chains, which are IPUT CHAIN, Forward Chain and
OUT PUT CHAIN.
Diagram Below shows high Level IP Packet Filtering in the “ IP Tables”
CN8822
Assignment #2
18
Our Assignment requirement is to Implement Basic IP table Rules at the INPUT chain
We have implemented the Rules by following commands
mangle
PREROUTING
nat
PREROUTING
filter
INPUT
filter
OUTPUT
nat
POSTROUTING
filter
FORWARD
Mangle
OUTPUT
route
Local
Process
Network
Network
CN8822
Assignment #2
19
Since IPTABLE Rules are sequential we have to be careful to have DROP Rule at the End of
The Rules.
We can verify our Rules by following Command.
Checked active ports on server
Using TCP dump to see the traffic on these ports.
CN8822
Assignment #2
20
CN8822
Assignment #2
21
References
http://chamibuddhika.wordpress.com/2012/03/21/ssh-tunnelling-explained/
Class Notes
www.uniforum.chi.il.us/slides/iptables_talk2/iptables_talk2.ppt	
http://ubuntuforums.org/showthread.php?t=1497376
http://fixunix.com/ssh/364505-running-multiple-sshd-instances-one-server.html

More Related Content

What's hot

Introduction to SSH
Introduction to SSHIntroduction to SSH
Introduction to SSHHemant Shah
 
An introduction to SSH
An introduction to SSHAn introduction to SSH
An introduction to SSH
nussbauml
 
Konfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCP
Konfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCPKonfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCP
Konfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCP
Walid Umar
 
Ssh tunnel
Ssh tunnelSsh tunnel
Ssh tunnel
Amandeep Singh
 
Os 2
Os 2Os 2
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
Varnnit Jain
 
Secure Shell(ssh)
Secure Shell(ssh)Secure Shell(ssh)
Secure Shell(ssh)
Pina Parmar
 
Ssh
SshSsh
Sshgh02
 
Intro to SSH
Intro to SSHIntro to SSH
Intro to SSH
JP Bourget
 
Mininet introduction
Mininet introductionMininet introduction
Mininet introduction
Vipin Gupta
 
Secure shell protocol
Secure shell protocolSecure shell protocol
Secure shell protocol
Baspally Sai Anirudh
 
SSH - Secure Shell
SSH - Secure ShellSSH - Secure Shell
SSH - Secure Shell
Peter R. Egli
 
Dhcp & dhcp relay agent in cent os 5.3
Dhcp & dhcp relay agent in cent os 5.3Dhcp & dhcp relay agent in cent os 5.3
Dhcp & dhcp relay agent in cent os 5.3Sophan Nhean
 
Ukk tkj p1 proxy mikrotik2014 2015
Ukk tkj p1 proxy mikrotik2014 2015Ukk tkj p1 proxy mikrotik2014 2015
Ukk tkj p1 proxy mikrotik2014 2015Riza Hafizhuddin
 

What's hot (17)

SSH Tunneling Recipes
SSH Tunneling RecipesSSH Tunneling Recipes
SSH Tunneling Recipes
 
Introduction to SSH
Introduction to SSHIntroduction to SSH
Introduction to SSH
 
An introduction to SSH
An introduction to SSHAn introduction to SSH
An introduction to SSH
 
Introduction to SSH & PGP
Introduction to SSH & PGPIntroduction to SSH & PGP
Introduction to SSH & PGP
 
Konfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCP
Konfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCPKonfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCP
Konfigurasi Server Gateway dengan fitur PROXY, WEBSERVER dan DHCP
 
Ssh tunnel
Ssh tunnelSsh tunnel
Ssh tunnel
 
Os 2
Os 2Os 2
Os 2
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
 
Secure Shell(ssh)
Secure Shell(ssh)Secure Shell(ssh)
Secure Shell(ssh)
 
Ssh
SshSsh
Ssh
 
Intro to SSH
Intro to SSHIntro to SSH
Intro to SSH
 
Mininet introduction
Mininet introductionMininet introduction
Mininet introduction
 
Secure shell protocol
Secure shell protocolSecure shell protocol
Secure shell protocol
 
SSH - Secure Shell
SSH - Secure ShellSSH - Secure Shell
SSH - Secure Shell
 
Dhcp & dhcp relay agent in cent os 5.3
Dhcp & dhcp relay agent in cent os 5.3Dhcp & dhcp relay agent in cent os 5.3
Dhcp & dhcp relay agent in cent os 5.3
 
Ukk tkj p1 proxy mikrotik2014 2015
Ukk tkj p1 proxy mikrotik2014 2015Ukk tkj p1 proxy mikrotik2014 2015
Ukk tkj p1 proxy mikrotik2014 2015
 
Advanced open ssh
Advanced open sshAdvanced open ssh
Advanced open ssh
 

Similar to openssh portforwarding and linux firewall

Complete MPICH2 Clustering Manual in Ubuntu
Complete MPICH2 Clustering Manual in UbuntuComplete MPICH2 Clustering Manual in Ubuntu
Complete MPICH2 Clustering Manual in Ubuntu
Minhas Kamal
 
RemoteAdmin.pptx
RemoteAdmin.pptxRemoteAdmin.pptx
RemoteAdmin.pptx
hoangdinhhanh88
 
Research and Analysis of SSH
Research and Analysis of SSH Research and Analysis of SSH
Research and Analysis of SSH
Matthew Chang
 
Nat mikrotik
Nat mikrotikNat mikrotik
Nat mikrotik
louisraj
 
Shutdown that bastion host!
Shutdown that bastion host!Shutdown that bastion host!
Shutdown that bastion host!
MichaelLudvig
 
Objective Modify a ProofofConcept PoC vsftpd 234 expl.pdf
Objective Modify a ProofofConcept PoC vsftpd 234 expl.pdfObjective Modify a ProofofConcept PoC vsftpd 234 expl.pdf
Objective Modify a ProofofConcept PoC vsftpd 234 expl.pdf
AAYAMINDIA
 
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloudSetting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
Loves Cloud
 
How to configure inband management for huawei ma5616
How to configure inband management for huawei ma5616How to configure inband management for huawei ma5616
How to configure inband management for huawei ma5616
Huanetwork
 
Ccna icnd1-labs - exercices
Ccna icnd1-labs - exercicesCcna icnd1-labs - exercices
Ccna icnd1-labs - exercices
saqrjareh
 
Interconnecting cisco networking devices part-1
Interconnecting cisco networking devices part-1Interconnecting cisco networking devices part-1
Interconnecting cisco networking devices part-1
DAVID RAUDALES
 
Saad baig practical file
Saad baig practical fileSaad baig practical file
Saad baig practical file
SaadBaig33
 
Mikro tik site to site eoip tunnel with i psec
Mikro tik site to site eoip tunnel with i psecMikro tik site to site eoip tunnel with i psec
Mikro tik site to site eoip tunnel with i psec
Uttam Ds
 
Tick Stack - Listen your infrastructure and please sleep
Tick Stack - Listen your infrastructure and please sleepTick Stack - Listen your infrastructure and please sleep
Tick Stack - Listen your infrastructure and please sleep
Gianluca Arbezzano
 
Student packet tracer manual v1.1
Student packet tracer manual v1.1Student packet tracer manual v1.1
Student packet tracer manual v1.1
milkux
 
7 hands on
7 hands on7 hands on
7 hands on
videos
 
Lan to lan vpn
Lan to lan vpnLan to lan vpn
Lan to lan vpn
Rohit Pardasani
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
Chef
 
Sc manual
Sc manualSc manual
Sc manual
MugdhaDeodhar
 
Time Series Database and Tick Stack
Time Series Database and Tick StackTime Series Database and Tick Stack
Time Series Database and Tick Stack
Gianluca Arbezzano
 

Similar to openssh portforwarding and linux firewall (20)

Complete MPICH2 Clustering Manual in Ubuntu
Complete MPICH2 Clustering Manual in UbuntuComplete MPICH2 Clustering Manual in Ubuntu
Complete MPICH2 Clustering Manual in Ubuntu
 
RemoteAdmin.pptx
RemoteAdmin.pptxRemoteAdmin.pptx
RemoteAdmin.pptx
 
Research and Analysis of SSH
Research and Analysis of SSH Research and Analysis of SSH
Research and Analysis of SSH
 
Nat mikrotik
Nat mikrotikNat mikrotik
Nat mikrotik
 
Shutdown that bastion host!
Shutdown that bastion host!Shutdown that bastion host!
Shutdown that bastion host!
 
Objective Modify a ProofofConcept PoC vsftpd 234 expl.pdf
Objective Modify a ProofofConcept PoC vsftpd 234 expl.pdfObjective Modify a ProofofConcept PoC vsftpd 234 expl.pdf
Objective Modify a ProofofConcept PoC vsftpd 234 expl.pdf
 
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloudSetting up a kubernetes cluster on ubuntu 18.04- loves cloud
Setting up a kubernetes cluster on ubuntu 18.04- loves cloud
 
How to configure inband management for huawei ma5616
How to configure inband management for huawei ma5616How to configure inband management for huawei ma5616
How to configure inband management for huawei ma5616
 
Ccna icnd1-labs - exercices
Ccna icnd1-labs - exercicesCcna icnd1-labs - exercices
Ccna icnd1-labs - exercices
 
Interconnecting cisco networking devices part-1
Interconnecting cisco networking devices part-1Interconnecting cisco networking devices part-1
Interconnecting cisco networking devices part-1
 
Openvpn
OpenvpnOpenvpn
Openvpn
 
Saad baig practical file
Saad baig practical fileSaad baig practical file
Saad baig practical file
 
Mikro tik site to site eoip tunnel with i psec
Mikro tik site to site eoip tunnel with i psecMikro tik site to site eoip tunnel with i psec
Mikro tik site to site eoip tunnel with i psec
 
Tick Stack - Listen your infrastructure and please sleep
Tick Stack - Listen your infrastructure and please sleepTick Stack - Listen your infrastructure and please sleep
Tick Stack - Listen your infrastructure and please sleep
 
Student packet tracer manual v1.1
Student packet tracer manual v1.1Student packet tracer manual v1.1
Student packet tracer manual v1.1
 
7 hands on
7 hands on7 hands on
7 hands on
 
Lan to lan vpn
Lan to lan vpnLan to lan vpn
Lan to lan vpn
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
 
Sc manual
Sc manualSc manual
Sc manual
 
Time Series Database and Tick Stack
Time Series Database and Tick StackTime Series Database and Tick Stack
Time Series Database and Tick Stack
 

Recently uploaded

原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
VivekSinghShekhawat2
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 

Recently uploaded (20)

原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 

openssh portforwarding and linux firewall

  • 1. CN8822 Assignment #2 2 Assignment 2 – Secure Remote administration and firewalls ________________________________ 3 Part1 _____________________________________________________________________________ 3 Objective: To Study the concepts of remotely administering a server using ssh.__________________ 3 Public-key authentication should be used for the root user __________________________________ 9 Part II-Objective: To study the concepts of ssh port forwarding._____________________________ 12 Part III -Objective: Firewall using IPTABLES ______________________________________________ 17 References ________________________________________________________________________ 21
  • 2. CN8822 Assignment #2 3 Assignment 2 – Secure Remote administration and firewalls Part1 Objective: To Study the concepts of remotely administering a server using ssh. 1)You are to secure a Linux server by restricting remote root access by running a separate sshd daemon. Make the necessary changes to have the newly configured sshd daemon comply with following restrictions: 1. Daemon must start on all run levels, i.e. 2345 2. root should have remote access to this server using new sshd daemon and no others. 3. All others should be accessing the server using the existing sshd daemon; again root should not be to access this sshd daemon. 4. Public-key authentication should be used for the root user 5. Feel free to add any configuration directives to further secure the ssh daemon Explanation: There is one SSH daemon runs by default to provide the ssh service on the default port 22. To have a separate SSH daemon we need to have separate run level and configuration files, and to isolate both daemons to work independently we copied binary file with different name . This was achieved by following these steps. 1) Copy sshd binary file with new name sshd_root with the –p option to retain same rights. 2) Copy sshd_config file with new name and make necessary changes to have separate keys for Root user and normal user, have separate pid file, separate port, separate Login Rules, these Rules are highlighted in the file
  • 3. CN8822 Assignment #2 4 Also have a separate PID file
  • 4. CN8822 Assignment #2 5 Here is the changes which have made in the sshd_root config file and we have highlighted them.
  • 5. CN8822 Assignment #2 6 3) Have separate init scripts for sshd daemon and sshd_root daemon, we have highlighted the Changes in both files . In the ssh script file we have pointed to correct config file Also changed the pid file name to new pid file all the corresponding functions. Similar changes were made in the ssh_root init script and we have highlighted them , most important change was to point to new binary sshd_root in the /usr/bin directory. Next change is point to right config file.
  • 6. CN8822 Assignment #2 7 3rd change was to have separate pid file as shown After all these changes we were able to successfully register the ssh_root as a separate daemon at the specified runlevels which is 2345 by using debian service register tool We can verify this by checking at the soft links at the rc startup level. After All these changes we were able to start/stop these two daemon separately and verified the login Rules. Here is the screenprint of separate pid files.
  • 7. CN8822 Assignment #2 8 We restarted the server and two daemons started independently. We tried to login as root on port 22 it failed Where as normal user login was successful. Similarly root login was successful at port 2501 and normal user failed on this port.
  • 8. CN8822 Assignment #2 9 Login as root was successful using port 2501 as shown. From this we were able to confirm that our two ssh daemon are working as expected in our Assignment. Public-key authentication should be used for the root user For the Public Key Authentication we used two machines with IP 192.168.56.101 as Server A And 192.168.56.102 as Server B and we were able to login with password. Here is the steps we had followed. 1) Create a key for root user
  • 9. CN8822 Assignment #2 10 2) Copy key to 192.168.56.102 using ssh-copy which copied the key to authorized directoy and Login to 192.168.56.102, login was successful without prompting for Password.
  • 11. CN8822 Assignment #2 12 Part II-Objective: To study the concepts of ssh port forwarding. SSH tunnels can be created in several ways using different kinds of port forwarding mechanisms. Ports can be forwarded in three ways. 1) Local port forwarding 2) Remote port forwarding 3) Dynamic port forwarding Port forwarding or port mapping is a name given to the combined technique of 1) translating the address and/or port number of a packet to a new destination 2) possibly accepting such packet(s) in a packet filter(firewall) 3 ) forwarding the packet according to the routing table. To illustrate Port Forwarding Example we have used Local port Forwarding. We have Two Servers A(192.168.56.101) and B (192.168.56.102) both have Apache running One Machine has default Apache test Page which we will treat as Client and Second Machine has Our Custom Page as shown below.
  • 12. CN8822 Assignment #2 13 This Machine we will treat as Server with IP 192.168.56.101 and Client one IP is 192.168.56.102 and Apache Page is We will use Local Port Forwarding on Client to Display the server Apache page To achieve this we will use SSH Local forwarding.
  • 13. CN8822 Assignment #2 14 SSH Local forwarding Syntax is ssh -L <local-port-to-listen>:<remote-host>:<remote-port> <gateway> In our case we have decided to use Local port 4500 to listen to remote server port 80 using Remote server as gateway. ssh –L 4500:192.168.56.101:80 root@192.168.56.101 Once we are logged into to Server 192.168.56.101, we will be listening port 80 traffic of this box to 192.168.56.102, 4500 port. We can confirm this by netstat
  • 14. CN8822 Assignment #2 15 192.168.56.102 port 4500 is opened as local host; we will access this from the box itself
  • 15. CN8822 Assignment #2 16 This confirms our configuration of Local port forwarding.
  • 16. CN8822 Assignment #2 17 Part III -Objective: Firewall using IPTABLES Firewall implementation using iptables. You are to setup the Appropriate iptables rules to accomplish the following: 1. Using the same VM running the newly configured sshd daemon From Part I; setup a default-deny policy to drop all inbound Traffic. 2. Only allow inbound traffic to both sshd ports, port 22 for public Access and privileged port for root access. Note: Privileged Port is something you choose in Part I when new daemon was Configured. 3. Only allow a trusted network or net-block to access the privileged sshd port. 4. Log all other dropped packets Explanations Firewalls are used to block unauthorized access to Network. All Linux Flavors provide basic firewall in the kernel “IPTABLES” which can be used to provide simple IPv4 and IPV6 packet filtering and Network Address Translation. IP Table provided three set of Rules, knows as chains, which are IPUT CHAIN, Forward Chain and OUT PUT CHAIN. Diagram Below shows high Level IP Packet Filtering in the “ IP Tables”
  • 17. CN8822 Assignment #2 18 Our Assignment requirement is to Implement Basic IP table Rules at the INPUT chain We have implemented the Rules by following commands mangle PREROUTING nat PREROUTING filter INPUT filter OUTPUT nat POSTROUTING filter FORWARD Mangle OUTPUT route Local Process Network Network
  • 18. CN8822 Assignment #2 19 Since IPTABLE Rules are sequential we have to be careful to have DROP Rule at the End of The Rules. We can verify our Rules by following Command. Checked active ports on server Using TCP dump to see the traffic on these ports.