Linux--ssh:connect to host localhost Port 22:connection refused

Source: Internet
Author: User
Tags ssh server

Today, when SSH password-free login, use SSH test, throw the following exception
Ssh:connect to host localhost Port 22:connection refused
Received on the Internet, a lot of answers, basically are
1. SSH not started
2. SSH not installed
3, the firewall is not closed
4 、...., uniform.
I looked at the solution above, but it still didn't work.

Research some of the data about SSH, the following
SSH: is a secure channel protocol, mainly used to realize the character interface of remote login, and other functions (using TCP port number 22nd). The SSH protocol encrypts the data transmitted by both parties, including the user password entered when the user logs in.
In Rhel 5 systems, OPENSSH servers are provided by packages such as Openssh,openssh-server, which are installed by default, and to add sshd as a standard system service.
SSH provides two ways of login verification:
1. Password Authentication: Authenticate with the login name and password of the local system user in the server.
2, the key pair verification: the need to provide matching key information to pass the authentication. Typically, you create a pair of key files (public and private) in the client computer, and then place the public key file at the specified location on the server.
Note: When both password authentication and private key authentication are enabled, the server takes precedence over key authentication.
Configuration file for SSH:
The configuration file of sshd service is/etc/ssh/sshd_config by default, and the related configuration items can be adjusted correctly to further improve the security of sshd remote login.
The contents of the configuration file can be divided into the following three sections:
1, the common SSH server monitoring options are as follows:
Port 22//listening on ports of 22
Protocol 2//using SSH V2 protocol
Listenadderss 0.0.0.0//The address of the listener is all addresses
Usedns no//Prohibit DNS reverse parsing
2. Common User Login Control options are as follows:
Permitrootlogin No//disable root user Login
Permitemptypasswords no//Disallow null password user login
Logingracetime 2m//Login verification time is 2 minutes
Maxauthtries 6//Maximum retry count is 6
Allowusers user//Allow user login only, contrary to denyusers option
3. Common login authentication methods are as follows:
Passwordauthentication Yes//enable password verification
Pubkeyauthentication Yes//enable key verification
Authorsizedkeysfile. Ssh/authorized_keys//Specify Public key database file
Reference: http://dengqi.blog.51cto.com/5685776/1260038

All of a sudden, I used ssh localhost, said 22 port reject link, when I looked at the SSH configuration file, I found the port number is 3228. Suddenly sharply

Checked the relevant information ssh-p3228 localhost, success.

Linux--ssh:connect to host localhost Port 22:connection refused

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.