Red Hat Enterprise Linux 9 Administration - Second Edition by Pablo Iranzo Gómez
Author:Pablo Iranzo Gómez
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2022-10-27T00:00:00+00:00
Advanced remote management â SSH tunnels and SSH redirections
SSH has two really powerful features; that is, SSH tunnels and SSH redirections. When an SSH connection is established, it can not only be used to send commands to the remote host and let us work on them as if they were our local system, but we can also create tunnels that interconnect our systems.
Letâs try to imagine a scenario that is common in many companies, where a virtual private network (VPN) is used to reach the internal network with all the services and servers, but with SSH instead of a regular VPN.
So, letâs put some context into this imaginary scenario.
We can use a host that gets external traffic for ssh redirected from our internet router to the ssh service in that system. So, in brief, our router gets connections on port 22 via TCP, and the connection is forwarded to our server. We will be naming this server bastion in this exercise.
With this in place, our common sense tells us that we will be able to reach that bastion host via SSH, even if we can use other tools or even ssh it to connect to other systems later.
Can we connect directly to other hosts in the internal network? The answer is yes, because, by default, SSH allows us to use TCP forwarding (sshd_config setting AllowTcpForwarding), which empowers us, as remote login users, to create port redirections and even a Socket Secure (SOCKS) proxy to be used for our connections.
For example, we can create a tunnel using that bastion host to reach our internal mail server via the Internet Message Access Protocol (IMAP) and Simple Mail Transfer Protocol (SMTP) protocols by just executing the following code:
ssh âL 10993:imap.example.com:993 âL 10025:smtp.example.com:25 user@bastionhost
This command will listen on local ports 10993 and 10025. All the connections that are performed there will be tunneled until bastionhost connects those to imap.example.com at port 993 and smtp.example.com at port 25. This allows our local system to configure our email account using those custom ports and use localhost as the server, and still be able to reach those services.
Tip
Ports under 1024 are considered privileged ports, and usually, only the root user can bind services to those ports. Thatâs why we use them for our redirection ports 10025 and 10093 so that those can be used by a regular user instead of requiring the root user to perform the ssh connection. Pay attention to ssh messages when youâre trying to bind to local ports in case those are in use, as the connections might fail. Furthermore, you can use additional -v, -vv, and -vvv modifiers to increase verbosity.
Additionally, from the target serverâs point of view, the connections will appear as if they originated in the bastion server as this is the one effectively performing the connections.
When the list of open ports starts to grow, it is better to go back to what we explained at the beginning of this chapter: the ~/.ssh/config file can hold the host definition, along
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide by Eric McLeroy(5835)
The KCNA Book by Nigel Poulton(4081)
Microsoft Security, Compliance, and Identity Fundamentals Exam Ref SC-900 by Dwayne Natwick(3443)
Designing and Implementing Microsoft Azure Networking Solutions by David Okeyode(3340)
Microsoft Security Operations Analyst Exam Ref SC-200 Certification Guide by Trevor Stuart and Joe Anich(3301)
Microsoft Security Operations Analyst Exam Ref SC-200 Certification Guide by Trevor Stuart & Joe Anich(3205)
TCP IP by Todd Lammle(2959)
Microsoft Power BI Data Analyst Certification Guide by Ed Corcoran Orrin Edenfield(2909)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2508)
Unity Certified Programmer: Exam Guide by Philip Walker(2387)
Networking A Beginner's Guide by Bruce Hallberg(2194)
Microsoft Power Platform Solution Architect's Handbook by Hugo Herrera(2014)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1847)
CompTIA A+ Practice Tests Core 1 (220-1101) and Core 2 (220-1102) by Ian Neil and Mark Birch(1771)
MCSA Windows Server 2016 Study Guide: Exam 70-741 by William Panek(1656)
PHP 7 Zend Certification Study Guide by Andrew Beak(1630)
Healthcare Information Security and Privacy (All-In-One) by Sean Murphy(1538)
CompTIA A+ Certification Guide (220-901 and 220-902) by Matthew Bennett(1515)
RHCSA & RHCE Red Hat Enterprise Linux 7: Training and Exam Preparation Guide (EX200 and EX300), Third Edition by Asghar Ghori(1472)
