How to use ssh remote connection in centos

WJ
Release: 2020-06-02 16:14:36
Original
4053 people have browsed it

How to use ssh remote connection in centos

Assume that the VPS uses centos, and then assume that the newer version 6.5 is used.

The desktop may not be installed on the VPS, but generally ssh will be installed, and the firewall will open port 22 by default.

Then start with ssh.

# 安装ssh,默认已安装好
# yum install ssh
# 启动ssh服务器端
# service sshd start
# chkconfig sshd on
Copy after login

ssh login

如果本地端是Linux
# ssh root@192.168.1.1
其中root表示的是登录用户名,192.168.1.1为主机的IP地址,当然也可以使用主机名、域名来指代IP地址。
# ssh 192.168.1.1
Copy after login

will log in with the user name of the current client.

ssh passwordless login

But it is very troublesome to enter a password to log in every time. Is there a way for the server to determine my identity and pass the authentication directly without entering a password?

In addition to using password verification, ssh also provides a public and private key verification method. The client generates a private key and a corresponding public key, and then uploads the public key to the server. Below is a Linux example.

Generate private key and public key on the client (note, complete on the client):

# ssh-keygen -t rsa
Copy after login

-t specifies the key type to be created, the default is rsa, so only execute ssh -keygen is the same.

During this period, you will be prompted to enter the encryption password of your private key. If you need to completely get rid of the password, you can leave it blank and press Enter directly, otherwise you will need to unlock it locally every time you connect in the future.

After completion, two files id_rsa and id_rsa.pub will be generated in the ~/.ssh/ path in the current user's home directory, which are the private key and the public key respectively.

Next, you need to upload the generated public key to the server, and also execute the following code on the client.

# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.1
Copy after login

Root can be changed to the server user name you want to log in automatically, and 192.168.1.1 can be changed to your VPS host name or IP address.

Finally, log in to the remote server via ssh.

# ssh root@192.168.1.1
Copy after login

You can log in without a password at this time.

Related references: centOS tutorial

The above is the detailed content of How to use ssh remote connection in centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!