Mac/linux ssh Password-free login configuration and error handling

Source: Internet
Author: User
Tags error handling scp command ssh config ssh config file

First of all, Mac and Linux are set up the same way

General practice can be referred to Http://www.tuicool.com/articles/i6nyei

First step: Generate the key. Execute the command under Terminal:

SSH-kegen-t RSA

All the way to enter, the various prompts by default do not change, wait for the completion of execution. Then execute:

ls ~/. SSH
#可以看到两个密钥文件: Id_rsa (private key) id_rsa.pub (public key)

Step Two: Place the public key to the Linux server. To use the SCP command:

SCP ~/. ssh/id_rsa.pub [email protected]:/home/cssor/. SSH/

Then add the id_rsa.pub content to the server side of the default authentication file Authorized_keys, execute:

~/. SSH Cat -n id_rsa.pub > Authorized_keys

Step Three: Configure the local SSH config file. Execution: (this optional, plus after the login will not have to knock a long list of server domain name, knock the individual name on the line, the proposed addition)

VI ~/. ssh/confighost zhangsan  #别名, domain abbreviation (note remember to erase)    HostName 192.168.100.100  #完整的域名    User Zhangsan  #登录该域名使用的账号名     ~/.  SSH/id_rsa #私钥文件的路径

After the above operation, has been completed, thanks to a colleague to help, although he is using the Ubuntu system.
Use SSH zhangsan or ssh [email protected] to log in directly to the remote server.

Problem handling

If you follow the above method or can not log in, you can first login to the remote server with a password and then enter the command:

Log file to view system with root User: $tail/var/log/secure-n 20

will prompt similar information:

.......  OCT7 Ten: -: +Masterserver sshd[2734]: Authentication Refused:bad ownership or modes for file/home/zhangsan/.SSH/authorized_keysoct7 Ten: -: -Masterserver sshd[2734]: Accepted Password forZhangsan from::1Port37456ssh2oct7 Ten: -: -Masterserver sshd[2734]: Pam_unix (sshd:session): Session opened forUser Zhangsan by (uid=0) Oct7 Ten: $: -Masterserver sshd[2809]: Accepted Password forZhangsan from192.168.1.241Port36257ssh2oct7 Ten: $: -Masterserver sshd[2809]: Pam_unix (sshd:session): Session opened forUser Zhangsan by (uid=0) Oct7 Ten: -: -Masterserver sshd[2857]: Authentication Refused:bad ownership or modes fordirectory/home/zhangsan/.SSH

What does the latest log mean? That means/home/hadooper/.ssh folder permissions on this path are incorrect.

Modify the following:

chmod  ~/. SSH chmod  ~/. SSH

If this is not the. SSH folder, but the user directory, such as/home/zhangsan, that is, your entire folder permissions are not right. (Note: File permissions are divided into two types ownership or modes)

My problem is that my account has root authority, my login account is not root, but is the owner of my folder permissions is root:root, estimated that SSH can not recognize, so use the following command to change the

You can have the permissions on the folder.

chown -R Zhangsan:zhangsan zhangsan/

At this point I solved the problem, if your log of the error message is other, then Baidu it separately. Another note: I am not Zhangsan

Mac/linux ssh Password-free login configuration and error handling

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.