ssh 无密码登录到 localhost

     2023-02-23     303

关键词:

【中文标题】ssh 无密码登录到 localhost【英文标题】:ssh password-less login to localhost 【发布时间】:2012-11-23 21:28:30 【问题描述】:

我正在尝试为分布式计算教程设置无密码登录到我的本地主机。 (我已经为多个远程主机成功设置了它。)我完成了生成 rsa 密钥并将公钥附加到authorized_keys 的正常步骤,但仍然提示我输入密码。我还在/etc/ssh_config 中启用了RSAAuthenticationPubKeyAuthentication。根据我看到的其他建议,我尝试了:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

但问题依然存在。

这是 ssh -v localhost 的输出:

(tutorial)bnels21-2:tutorial bnels21$ ssh -v localhost
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: identity file /Users/bnels21/.ssh/id_rsa type 1
debug1: identity file /Users/bnels21/.ssh/id_rsa-cert type -1
debug1: identity file /Users/bnels21/.ssh/id_dsa type -1
debug1: identity file /Users/bnels21/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9
debug1: match: OpenSSH_5.9 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 1c:31:0e:56:93:45:dc:f0:77:6c:bd:90:27:3b:c6:43
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /Users/bnels21/.ssh/known_hosts:11
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/bnels21/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Offering RSA public key: id_rsa3
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /Users/bnels21/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Password:

有什么建议吗?我正在运行 OSX 10.8。

【问题讨论】:

这个连接尝试的 sshd 服务器日志中有什么内容? 这是我从 /var/log/system.log 得到的:Dec 5 16:52:04 phyleaux4biologylsuedu.local sshd[54115]: Connection closed by ::1 [preauth] Dec 5 16 :52:06 phyleaux4biologylsuedu.local netbiosd[109]:名称服务器停机? 我应该在其他地方寻找 sshd 服务器日志吗? 【参考方案1】:

我束手无策...我误以为ssh-copy-id 是一个仅限Linux 的实用程序。最后我忍住了我的骄傲,输入了命令是 macOS 终端,它成功了!

ssh-copy-id me@sshd-server

我不知道ssh-copy-id 有什么魔力,但它确实有效。我可以使用简单的命令在没有密码的情况下成功登录:

ssh me@sshd-server

我对@9​​87654325@ 的运气为零。每次我尝试通过 ssh 连接到服务器时,它都会不断询问我的密码。这是在 authorized_hosts 和 700 ~/.ssh 上的正确 600 权限。

【讨论】:

【参考方案2】:

我有同样的问题。我检查了系统密码和组文件,发现我的用户和组不存在。要构建这些文件(我的用户是域用户),我需要在 cygwin shell 中运行两个命令:

mkpasswd -l -d > /etc/passwd

mkgroup -l -d > /etc/group

之后,ssh 就可以正常工作了!

埃尔维斯·博尔赫斯

【讨论】:

【参考方案3】:

您在连接到localhost 时似乎使用的是协议版本 2.0,因此请尝试将 authorized_keys 移动到 authorized_keys2

来源:this post 解释了两个密钥文件的区别。

【讨论】:

【参考方案4】:

由于您似乎有多个键,我会将特定键分配给 ~/.ssh/config 中的特定连接。

例子:

Host local
    HostName 127.0.0.1
    Port 22
    User your_username
    IdentityFile ~/.ssh/your_key-id_rsa

那就试试ssh local吧。

【讨论】:

在 OS X 上设置无密码 ssh 到 localhost

】在OSX上设置无密码ssh到localhost【英文标题】:SetuppassphraselesssshtolocalhostonOSX【发布时间】:2011-10-3108:42:16【问题描述】:我正在尝试让Hadoop的伪分布式操作示例(http://hadoop.apache.org/common/docs/stable/single_node_setup.html)在OSXLion上运行... 查看详情

ssh已经设置无密码登录了,但hadoop启动时提示要输入localhost的密码,具体情况如问题补充,求大神解救

...oop-1.2.1/libexec/../logs/hadoop-root-namenode-Lenovo-IdeaPad-Y480.outroot@localhost'spassword:root@localhost'spassword:localhost:Permissiondenied,pleasetryagain.localhost:Permissiondenied,pleasetryagain.root@localhost'spassword:localhost:Permissiondenied(publickey,password).root@localho... 查看详情

rhel7.2ssh无密码登录非root用户

1修改三台虚拟机的/ect/hosts文件[[email protected]~]$cat/etc/hosts127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6[[ 查看详情

ssh设置无密码登录

设置无密码登录此处设为有主机a登录到主机b1、在主机a生成公钥 ssh-keygen-trsa 之后有导航(其实一直回车就可以)2、此时在主机a/home/YOURHOSTNAME/.ssh下面有一个id_rsa和id_rsa.pub3、查看在主机b的/home/YOURHOSTNAME下有一个.ssh文件... 查看详情

ssh常用命令

...从某主机的80端口开启到本地主机2001端口的隧道ssh-N-L2001:localhost:80somemachine现在你可以直接在浏览器中输入http://localhost:2001访问这个网站。3、将你的麦克风输出到远 查看详情

linux下怎样设置ssh无密码登录

...uot;,想以用户“aliceB”的身份ssh到hostB上,但又不想输入密码。首先,你需要以用户“aliceA”的身份登录到hostA上。然后,使用ssh-keygen生成一对rsa公私钥,生成的密钥对会存放在~/.ssh目录下。接下来,使用下面的命令在目标主机... 查看详情

linux下怎样设置ssh无密码登录

在CentOS/RHEL上设置SSH免密码登录导读作为系统管理员,你计划在Linux上使用OpenSSH,完成日常工作的自动化,比如文件传输、备份数据库转储文件到另一台服务器等。为实现该目标,你需要从主机A能自动登录到主机B。自动登录也... 查看详情

centos下ssh配置无密码登录(代码片段)

...#xff1a;sudoapt-getinstallssh启动SSH服务:servicesshdrestartSSH无密码登录的原理如下假设A机器想要通过SSH无密码登录访问B机器,则需要在A机器上生成一对秘钥(公钥+私钥),而后将公钥复制到B机器上;当A机 查看详情

ssh无密码登录验证技术

...还需有直接发送数据到WEB服务器上的功能,这里使用ssh无密码登录验证技术实现。 首先在要添加信任关系的每台服务器上修改hosts文件vi/etc/hosts在下面添加:把各服务器的IP和主机名一一对应添加,注意区分大小写650)this.width=6... 查看详情

ssh无密码登录的原理及配置

 一、SSH概念(百度)SSH为SecureShell的缩写,由IETF的网络小组(NetworkWorkingGroup)所制定;SSH为建立在应用层基础上的安全协议。SSH是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议。利用SSH协议可以有效防... 查看详情

centos系统实现ssh无密码登录的方法

...2、客服端:CentOSrelease5.8IP:192.168.4.244  二、配置SSH无密码登录需要3步:  1、生成公钥和私钥  2、导入公钥到认证文件,更改权限  3、测试  三、客户端配置  1、在客户端生成私钥与公钥;    #ssh-keygen  ... 查看详情

linux下怎样设置ssh无密码登录

步骤主机A:192.168.1.110主机B:192.168.1.111需要配置主机A无密码登录主机A,主机B先确保所有主机的防火墙处于关闭状态。在主机A上执行如下: 1. $cd~/.ssh 2. $ssh-keygen-trsa--------------------然后一直按回车键,就会按照默认的选项... 查看详情

利用ssh-copy-id实现ssh无密码登录

第一步:产生公钥与私钥对:[[email protected]]# ssh-keygen -t rsa按照提示输入完后,会在~/.ssh目录下生成id_rsa和id_rsa.pub这两个文件 第二步:用ssh-copy-id将公钥复制到远程机器中ssh-copy-id 将本机的公钥复制到远程机... 查看详情

ssh无密码登录

ssh-copy-id+portssh-keygenssh-copy-id-i/path/to/id_foobar.pub"-p2342[email protected]" 查看详情

ssh无密码登陆(代码片段)

本文引用自:Linux大神博客的博文 SSH无密码登录:只需两个简单步骤(Linux)如果你管理一台Linux服务器,那么你就会知道每次SSH登录时或者使用scp复制文件时都要输入密码是一个多么繁琐的过程.这篇教程介绍使用SSHKey来实现S... 查看详情

ssh无密码登录

SSH无密码登录配置(通过公私钥)主机A:172.16.11.99主机B:10.0.0.100前提条件:A、B间能够互通(可以ping通) 步骤:1、在主机A中,使用ssh-keygen命令生成公私密钥对[[email protected] ~]# ssh-keygen然后一直按回车键,就会... 查看详情

ssh无密码登录:只需两个简单步骤(linux)

...你就会知道每次SSH登录时或者使用scp复制文件时都要输入密码是一个多么繁琐的过程.这篇教程介绍使用SSHKey来实现SSH无密码登录,而且使用scp复制文件时也不需要再输入密码.除了方便SSH登录,scp复制文件外,SSH无密码登录也... 查看详情

ssh配置无密码登录

1.在master机器上生成公钥:[[email protected]~]#ssh-keygen-trsa  注:一直按enter键就可以生成了Generatingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa): Createddirectory‘/root/. 查看详情