Being a Linux administrator is not complete without understanding SSH. It is the main tool to connect to an operating system instance to access the command line interface. This tool is used by nearly every Linux administrator on a daily basis. Due to lack of security features, it has replaced legacy tools like rlogin or telnet. SSH is very secure and robust. Let’s learn more about SSH.
What are SSH directories?
SSH has two main directory tree branches. Each tree serves a specific purpose. This is primarily about whether the application is applicable to the entire system, or just to the user. Some apply to an SSH client and others to an SSH server.
The directory /etc/ssh/
The system-wide configuration of /etc/ssh/ is available. These are the defaults and are rarely modified. These may be modified to make a system more secure or to set defaults for companies. These may be updated as newer versions of the software are released. Sometimes older options are removed or deprecated.
This directory contains two main files: ssh_config, and sshd_config.
Everything LinuxRelated Training from SPOTO
Start trainingThe ssh_config is used for client-based connections outbound towards servers. This file contains any company defaults/standards that are modified or inserted. This file can also be reviewed to determine if there are any factory defaults for outbound connections.
The sshd_config contains settings for SSH server side connections. Here you can set things like whether root login is allowed or what ciphers may be used. You can also find options such as user-specific access, which is discussed further below.
The /.ssh/ directory
This directory is specific to a user’s ssh configuration. This configuration can have private keys, accepted keys, and configuration options for remote connections. The tilde (), an alias for the current user’s home directory, would be pointing to /home/testuser.
The basic security feature of SSH is the known_hosts file. It will prompt you to accept the identity of remote servers each time you connect to them. If you answer yes, it adds that information to known_hosts. This is useful in case your identity information changes. It can detect unexpected changes or Man In the Middle Attacks where someone attempts to hijack your connection.
SSH allows you key-based authentication instead of passwords. We’ll talk about how to generate it later with ssh_keygen. However, this requires a private key and a shared public key. After you have appended your public key to the file, it will accept key-based authentication.
Once a key has been successfully generated, the private key is automatically generated with the name id_rsa for RSA keys. The complementary public key is called id_rsa.pub. While the public key can be shared with no problem, the private key should remain highly secured and not be shared.
What are SSH Commands and how do they work?
Most people are familiar with the “ssh”, which is used to connect to different servers. There are many more commands, but they aren’t always used every day. Some commands are essential while others are nice to have as helper commands.
ssh-copy-id
Although it is not essential, the ssh copy-id command makes life easier. It is one of the helper commands that was mentioned. It copies your public key to a server. The key is not yet stored on the server so it will likely use password-based authentication to copy it, but allow for key authentication to connect to other connections.
This can be done manually by sshing in and manually editing the authorized_keys files and appending your public key. Sometimes, you might need to create authorized_keys.
0