Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing and setting SSH Server on Ubuntu Server

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install and set up SSH Server on the Ubuntu server". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to install and set up SSH Server on the Ubuntu server".

Preparation before installation

Ubuntu works well because it inherits debian's apt system, which I'm sure you already felt in the tutorial where you installed the system yesterday. But apt needs to rely on the network, the system we installed yesterday is temporarily unable to go online, we need to set it up first.

First, activate the server's network card with the following command:

Sudo nano / etc/network/interfaces

Add the following to interfaces:

Auto eth0 iface eth0 inet static address 202.113.235.181 netmask 255.255.255.0 gateway 202.113.235.1

Among them, the IP address marked in italics is the setting of our server, which you need to modify according to your specific situation. Of course, if your server uses DHCP to assign IP addresses, you just need to write iface eth0 inet dhcp instead of setting up address/netmask/gateway.

Then, modify the resolv.conf configuration DNS server:

Sudo nano / etc/resolv.conf

Add your DNS server address:

Nameserver 202.113.16.10 nameserver 202.113.16.11

When finished, restart the networking service:

Sudo / etc/init.d/networking restart

This should be able to connect to the network. If you are using ADSL, you may also need to install something like pppoe, which is not discussed here, considering that the server rarely uses such a configuration. You can look it up on the Internet if necessary.

Install and set up OpenSSH Server

It is extremely easy to install OpenSSH Server under Ubuntu, and only one command is required:

Sudo apt-get install openssh-server

Ubuntu then automatically downloads and installs openssh server and resolves all dependencies. When you are done, you can find another computer and enter the IP address of your server using a SSH client software (highly recommended PuTTy). If everything is all right, it will be connected in a moment. And you should be able to log in with your existing username and password.

In fact, if you don't have any special needs, you can install OpenSSH Server here. But if you set it up further, you can make OpenSSH login time shorter and more secure. This is all done by modifying openssh's configuration file, sshd_config.

First of all, when you were experimenting with remote login, you may find that it takes a long time to prompt for a password after entering a user name. In fact, this is because sshd needs to reverse check the dns information of the client. We can greatly increase the speed of login by disabling this feature. First, open the sshd_config file:

Sudo nano / etc/ssh/sshd_config

Find the GSSAPI options section and comment out the following two lines:

# GSSAPIAuthentication yes # GSSAPIDelegateCredentials no

Then restart the ssh service:

Sudo / etc/init.d/ssh restart

Try logging in again. It should be very soon.

Using PuTTy to log in to the server through certificate authentication

In the SSH service, all the content is encrypted and the security is basically guaranteed. However, if you can use certificate authentication, security will be asked to climb another high-rise building, and after a certain setting, it can also achieve the effect of automatic login of certificate authentication.

First, modify the sshd_config file to enable the certificate verification option:

RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile h/.ssh/authorized_keys

Restart the ssh service after the modification is complete.

Next we need to establish the private and public keys for the SSH user. The first step is to log in to the account that needs to establish a key. Here, pay attention to logging out of the root user, and use the su command to switch to another user if necessary. Then run:

Ssh-keygen

Here, we can store the generated key in the default directory. During the establishment process, you will be prompted to enter passphrase, which is equivalent to adding a password to the certificate, and it is also a measure to improve security, so that you are not afraid even if the certificate is accidentally handcuffed. Of course, if this is left blank, the automatic login of PuTTy through certificate authentication can be realized later.

The ssh-keygen command generates two keys. First we need to rename the public key and leave it on the server:

Cd / .ssh mv id_rsa.pub authorized_keys

Then copy the private key id_rsa from the server and delete the id_rsa file on the server.

The settings on the server are done, and the following steps need to be done on the client computer. First, we need to convert the id_rsa file to a format supported by PuTTy. Here we need to use PuTTyGEN as a tool:

Click the Load button in the PuTTyGen interface, select the id_rsa file, enter passphrase (if any), and then click the Save PrivateKey button, so that the private key accepted by PuTTy is done.

Open PuTTy, enter the IP address of the server in Session, click the Browse button under Connection- > SSH- > Auth, and select the private key you just generated. Then go back to the Connection option and enter the user name to which the certificate belongs in Auto-login username. Go back to the Session tab and enter a name and click Save to save the Session. Click the Open at the bottom and you should be able to log in to the server with certificate authentication. If you have passphrase, you will be asked to enter passphrase during the login process, otherwise you will log in directly to the server, which is very convenient.

Thank you for reading, the above is the content of "installation and setup of SSH Server on Ubuntu server". After the study of this article, I believe you have a deeper understanding of the installation and setting method of SSH Server on Ubuntu server, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report