loading...

Linux Mint – Accessing your system via SSH

How to Install MySQL 8.0 on Ubuntu 18.04

By default, the ssh command is available in Linux Mint without the need to install any extra packages. You can connect to other machines via SSH using your Linux Mint computer right away. However, only the package that enables you to connect to other machines is installed and not what’s required to connect to your own machine from a different computer. If you would like to access your own computer via SSH, the openssh-server package must be installed. To do so, first run the following command:


sudo apt-get install openssh-server

You’re still not done. Once the openssh-server package is installed, you must designate which user accounts are allowed to access your system remotely. To do this, we need to edit a configuration file, and this file is the sshd_config file that is located in the /etc/ssh directory.

However, before editing it, it’s a good idea to make a backup copy should you make a mistake. To do so, execute the following command line:


sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

To edit the sshd_config file, run the following command:


sudo nano /etc/ssh/sshd_config

Once the file is open in the nano text editor, scroll to the very bottom and press Enter to create a new line beginning with AllowUsers, followed by the usernames to which you would like to provide access. (The
AllowUsers clause is the one that allows access into your system.) If you would like to use the machine remotely as yourself, enter your own username. For example, if you wanted to give a user jdoe access to your machine via SSH, you would add the following line to the end of the file:


AllowUsers jdoe

If you would like to give more than one user access to the system, type their username(s) in the same line as shown in the following line of code:


AllowUsers jdoe bsmith bdole

Note

Another entry in the sshd_config file that you may want to consider looking at is the port that the SSH service listens on. This is typically located at the top of the sshd_config file. If port 22 isn’t allowed in your environment, you may wish to change this.

Then, save the file by pressing Ctrl + O. You can then press Enter to confirm and then Ctrl + X to exit the editor. Now that you have edited the sshd_config file with the required changes, you must restart the SSH service in order for it to recognize the changes. To do so, enter the following command:


sudo service ssh restart

As long as there are no errors, your system is now ready for SSH access. If the restart command complains about something you entered into the sshd_config file, edit the file again to correct the problem, and then try restarting SSH again.

Now that SSH is enabled and you’ve set up SSH access on your system, try connecting to it from another machine on your network. If you only have one computer running Linux, you can download the PuTTY program to access your Linux computer from Windows. (Mac OS X computers should be able to access other computers via SSH by default.) To download PuTTY for Windows, navigate to the following URL via your browser:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

With a Linux computer, you can access another Linux computer via SSH using the ssh command as mentioned in the previous section. However, to summarize, assume that the command is in the following format:


ssh user@192.168.0.1

In the preceding line, just replace user with the required username and the IP address with the actual IP address of the system you would like to connect to.

Note

By default, SSH will use the username you’re currently using for the connection. In the previous example, prefixing the command with user@ tells SSH to use a specific user account on the target system. If the username is the same on both machines, you can leave this part out. Also, if port 22 is blocked in your environment and you want to set it to listen on a different port, append the -p option along with the port number to the command.

Once you get connected via SSH, you are able to remotely administer the target system as if you were sitting in front of it.

Comments are closed.

loading...