无密码SSH登录

时间:2016-02-27 05:15:56

标签: macos ssh centos

我想在没有密码的情况下登录我的服务器,我在服务器localhost上取得了成功,但是当我尝试从我的mac pro登录时失败了。

首先,我在我的服务器上进行测试。

  1. 第1步:生成密钥 enter image description here

  2. 第2步:cat到authorized_keys,并尝试无密码SSH登录localhost,没有问题。 enter image description here

  3. 所以,我在我的mac pro

    上试试这个
    1. 第3步:生成密钥 enter image description here

    2. 步骤4:将公钥复制到我的服务器,然后cat到authorized_keys enter image description here

    3. 步骤5:尝试在我的mac pro上登录我的服务器,仍然需要密码 enter image description here

    4. 第6步:我谷歌“无密码SSH登录”,并在SSH上找到名为authorized_keys的文件应具有权限600& 〜/ .ssh目录一般应该有权限700.所以我做了以下步骤 enter image description here

    5. 第7步:仍然需要密码 enter image description here

    6. 有人可以帮助解决这个问题吗?我的mac是OS X 10.11,我的服务器是CentOS 7.0 64bit

      更新

      1. 配置是authorized_keys enter image description here

2 个答案:

答案 0 :(得分:0)

你的过程看起来很好,但对于MAC你似乎缺少一个关键步骤;

sudo systemsetup -setremotelogin on

如上所述,您需要通过setremotelogin配置MAC以接受远程登录。

答案 1 :(得分:0)

我发现RHEL 7和SELinux是根本原因,即使在调整了/ etc / ssh / sshd_config中的每个变量并生成了比锁匠更多的密钥之后。以root身份登录,然后运行:

    setsebool -P use_nfs_home_dirs 1

您仍然需要创建密钥,与其他主机登录共享。我的问题是我们使用基于NFS的" home"目录,所以SELinux不允许没有这个显式标志的访问。

如果您的问题消失,请告诉我。

相关问题