Ssh password-free login, ssh password login

Source: Internet
Author: User

Ssh password-free login, ssh password login

Assume that the master machine A, B, and C needs to be established as the master machine A. You can directly access the master machine B and C through ssh without A password. The procedure is as follows:

Assume that you only use the user yimr to establish trust, use the yimr user to log on to host A and perform the following operations:

  • Generate public and private keys

ssh-keygen -t rsa

Then, the id_rsa and id_rsa.pub files are generated under the/home/user/. ssh directory.

  • Copy the public key to the BC Node

Scp. ssh/id_rsa.pub B:/home/username/. ssh/A. pub


  • Go to the BC node and put the public key in the authorized_keys file.

cat .ssh/A.pub >> .ssh/authorized_keys

  • Permissions of machines A, B, and C must be modified.

chmod 755 .sshchmod 600 .ssh/authorized_keys

  • A, B, and C each machine must modify the sshd configuration file vim/etc/ssh/sshd_config
RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile      .ssh/authorized_keysGSSAPIAuthentication noUseDNS no


  • Restart SSHD service
service sshd restart


  • Done






How can I use SecureCRT to log on to a linux host using ssh without a password?

1. Generate a key on the client. The command is as follows:
Ssh-keygen
* 2. Check whether the key permissions and directory permissions are 600 and 700 respectively, and the ower is the ower.
3. Copy the generated public key to the server and add it to. ssh/authorized_keys (if the path information of the AuthorizedKeysFile parameter in the configuration file has not been modified), run the following command:
Scp ~ /. Ssh/id_rsa.pub serverssh @ ip :~
Ssh serverssh @ ip
* Mkdir ~ /. Ssh; chmod 700 ~ /. Ssh
Cat ~ /Id_rsa.pub> ~ /. Ssh/authorized_keys
* Chmod 644 ~ /. Ssh/authorized_keys

In this way, it is better to ask for a key prompt, and the step permissions plus * should not be wrong.

Use SSH authentication to log on without a password. However, you still need to enter a password when executing sudo. What is the password?

When the root user is not set a password, The sudo password should be the password of your current account. The password that you need to enter when creating the system.

(1) switch from user to root user
Whether logging on to Ubuntu in graphical mode or logging on in command line mode, we will find that the default user is user
However, when we need to perform operations with root permissions (such as repairing and returning system files), we often need to use sudo authorization, which is very troublesome.
Now we can switch to the root user, just execute sudo su.
Note: For security reasons, by default, the root user of Ubuntu does not have a fixed password. The password is randomly generated and dynamically changed.
Is changed every five minutes, so su (switch user) is not allowed, because we do not know the root password.

(2) switch from root user to user
To switch the user from the root user back to the user, you only need to execute the command: su user (user is the user name when you install the user), or directly enter exit, you can also press Ctrl + D to launch

(3) set a password for the root user.
By default, the root user has no fixed password and is locked. If you want to set a password for the root user
You only need to execute the command: sudo passwd root and then follow the prompts one step at a time.
In this way, you can enter the root password to switch to the root user as mentioned in (1 ).
Note: After setting the password for the root user, you can still switch sudo su to the root user.
Appendix: in graphic mode, choose system> System Management> users and groups. You can also set a password for the root user.

Hope to help you.

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.