Read a sample: 1. A Safe Place to Practice
A remote shell gives you a way to work on one computer while sitting at another. The commands may look familiar, but their effects occur on the machine that receives them. That distinction is the foundation of this book: before you make a change, you need to know which account is acting, which host is receiving the command, and whether the work is authorized.
You do not need a rack of servers to practice. A small lab can consist of your everyday computer and one Linux virtual machine running on it. Your everyday computer acts as the client: it starts the connection. The virtual machine acts as the server: it accepts connections for a lab account. Although both may use the same physical hardware, treating them as separate systems will help you develop habits that carry over to remote work.
This chapter prepares that lab and gives you a way to read the examples that follow. You will identify the two systems, record the details needed for a later connection, and establish a boundary around what you are permitted to access. You do not need to complete an SSH login yet. Later chapters will walk through the connection and verification steps.
Use a machine you own or a lab environment for which you have explicit permission. Permission to use a network does not, by itself, authorize you to probe other devices on it or attempt to log in to them. Likewise, a working password or a discovered address is not an invitation to connect.
For this book, the intended target is a disposable Linux server or virtual machine created for your practice. Keep the exercises inside that environment unless an administrator has approved a different target and the work you intend to perform. If you are using an employer’s lab, follow its access and data-handling rules as well.
A useful practice server has three qualities:
- It contains no important or sensitive data.
- You can reach its console independently of SSH.
- You can restore or rebuild it if an exercise goes wrong.
The console is the screen and input provided directly by your virtualization software or hosting environment. It is different from an SSH session: you can often use it even when the server’s network connection or SSH configuration is broken. Keep that route available throughout the exercises.
A snapshot or other recovery method can make experimentation easier, but it is not a substitute for understanding what a command will do. Check the instructions for your virtualization software before relying on a snapshot, and avoid placing valuable work only inside a disposable lab.
The examples in this book use these fictional lab details:
The address 192.0.2.10 is an example, not an address you should expect to reach in your own lab. Replace it with the address assigned to your server. Similarly, use your actual server account name, hostname, and port wherever an example calls for them. Names are useful labels, but an address or name in a command must identify the server you have been authorized to use.
Your client may be a Linux machine, another Unix-like system, or a computer with an SSH client available in its terminal. The remote exercises in this book target Linux. The exact menus for creating a virtual machine depend on your virtualization software, but the choices you need to make are straightforward:
1. Create a Linux virtual machine using an installation image from a source you trust.
2. Give the virtual machine enough resources to boot and run a terminal comfortably.
3. Create a regular, non-root user account for practice.
4. Enable networking appropriate to your lab.
5. Install and start the distribution’s SSH server if it is not already available.
6. Keep the virtual machine console accessible.
Distribution installers and package names differ, so consult your distribution’s documentation for its current installation and service-management steps. Some images include an SSH server; others do not. An SSH client installed on the server is not necessarily the same thing as an SSH server that is running and accepting connections.
Use a regular account such as trainee for ordinary work. If an exercise requires administrative action during setup, use only the privileges you have intentionally granted yourself, and return to the regular account afterward. There is no need to enable direct root login for the exercises in this book.
A virtual machine must be reachable from the client, but it does not need to be exposed broadly. Your virtualization software may offer several networking modes. Their names and behavior vary, so check its documentation before choosing one.
A host-only network generally connects the host computer and selected virtual machines on a private virtual network. It can be a convenient choice when both client and server are on the same physical computer. A bridged network places the virtual machine on a network alongside other devices; that may make the server reachable by more systems than you intend. A NAT arrangement commonly lets a virtual machine make outbound connections, but reaching it from the host may require additional configuration, such as a forwarded port.
For a first lab, choose the least exposed arrangement that lets your client reach the server and that you understand well enough to manage. Do not enable a port forward to the wider network merely because an online example does so. If you use a managed lab, follow its network instructions…