Ubuntu Config SSH service

Source: Internet
Author: User
Tags ssh server

First try ssh localhost

ssh localhost

If the SSH service is not started, the following error will be reported:

ssh: connect to host localhost port 22: connection refused
Set SSH password-free login (optional)

This step sets the password-free login by setting the public and private keys. You can skip this step if the server is logged in with a username and password.
Running the following command generates a bunch of keys id_rsa and id_rsa.pub in the ~/.ssh/directory:

ssh-keygen

To enter the following prompt information, the key pair will be generated in the default location ~/.ssh/directory, and we set passphrase to empty, that is, no password login.
Use the following command to join the newly generated public key to the authorized key list file Authorized_keys (because there is no Authorized_keys file at the beginning, so use the CP command here):

cp ~/.ssh/id_isa.pub ~/.ssh/authorized_keys

Make sure that the. SSH directory and the Authorized_keys file have only the user's own Write permission, otherwise the validation is not valid

chomd 600 ~/.ssh/authorized_keyschmod 700 ~/.ssh
Open SSH Service

Configure the non-secret login still cannot ssh localhost, because Ubuntu default does not install and open the SSH server, therefore, we also need:
1. Determine the installation of sshd

sudo apt-get install openssh-server

2. Start sshd

sudo net start sshd

3. Check the firewall settings and turn off the firewall

sudo nfw disable

4. Verify the success, run the following command

ssh localhost

Sometimes although successful, but still will appear connection refused problem, this is, need to check whether the sshd process is started.
Run the following command to see if there is an sshd process:

ps -e | grep ssh

Sometimes although you can see the sshd, but still cannot connect successfully, this is the need to restart SSH:

sudo service ssh restart

Then connect again.

Ubuntu Config SSH service

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.