全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

Hadoop SSH免密码登录以及失败解决方案

1. 创建ssh-key

这里我们采用rsa方式,使用如下命令:

xiaosi@xiaosi:~$ ssh-keygen -t rsa -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Created directory '/home/xiaosi/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/xiaosi/.ssh/id_rsa.
Your public key has been saved in /home/xiaosi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:n/sFaAT94A/xxxxxxxxxxxxxxxxxxxxxxx xiaosi@xiaosi
The key's randomart image is:
+---[xxxxx]----+
|    o= .. .. |
|    o.= .. .|
|     *.* o .|
|    +.4.=E+..|
|    .SBo=. h+ |
|    ogo..oo. |
|     or +j..|
|     ...+o=.|
|     ... o=+|
+----[xxxxx]-----+

备注:

这里会提示输入pass phrase,一定不要输入任何字符,回车即可。

2. 生成authorized_keys文件

xiaosi@xiaosi:~$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

备注:

记得要把authorized_keys文件放到.ssh目录下,与rsa等文件放在一起,否则免登录失败,debug如下(ssh -vvv localhost进行调试,查找错误原因):

xiaosi@xiaosi:~$ ssh -vvv localhost
OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g-fips 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "localhost" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/xiaosi/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/xiaosi/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu1 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to localhost:22 as 'xiaosi'
debug3: hostkeys_foreach: reading file "/home/xiaosi/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/xiaosi/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:378enl3ckhdpObP8fnsHr1EXz4d1q2Jde+jUplkub/Y
debug3: hostkeys_foreach: reading file "/home/xiaosi/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/xiaosi/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from localhost
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/xiaosi/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/xiaosi/.ssh/id_rsa (0x5602df5e80c0)
debug2: key: /home/xiaosi/.ssh/id_dsa ((nil))
debug2: key: /home/xiaosi/.ssh/id_ecdsa ((nil))
debug2: key: /home/xiaosi/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/xiaosi/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/xiaosi/.ssh/id_dsa
debug3: no such identity: /home/xiaosi/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/xiaosi/.ssh/id_ecdsa
debug3: no such identity: /home/xiaosi/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/xiaosi/.ssh/id_ed25519
debug3: no such identity: /home/xiaosi/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
xiaosi@localhost's password: 

3. 验证

xiaosi@xiaosi:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:378enl3ckhdpObP8fnsHr1EXz4d1q2Jde+jUplkub/Y.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
sign_and_send_pubkey: signing failed: agent refused operation
xiaosi@localhost's password: 

4. authorized_keys权限

我们可以看到还是让我输入密码,很大可能是authorized_keys文件权限的问题,我们给该文件赋予一定权限:

xiaosi@xiaosi:~$ chmod 600 ~/.ssh/authorized_keys

再次验证:

xiaosi@xiaosi:~$ ssh localhost
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-24-generic x86_64)
 * Documentation: https://help.ubuntu.com/
0 个可升级软件包。
0 个安全更新。
Last login: Thu Jun 16 08:05:50 2016 from 127.0.0.1

到此表示OK了。

备注:

或者第一次需要输入密码,以后再次登陆就不需要输入密码了。

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


# Hadoop  # SSH免密码登录以及失败原因解决办法  # SSH  # SSH免密码登录  # Hadoop框架起步之图解SSH、免密登录原理和实现方法  # Hadoop脚本远程控制中SSH常见问题详解  # 输入密码  # 让我  # 就不  # 要把  # 希望能  # 软件包  # 可以看到  # 谢谢大家  # 到此  # 该文件  # 放在一起  # 目录下  # Enabling  # remote 


相关文章: 番禺网站制作公司哪家值得合作,番禺图书馆新馆开放了吗?  平台云上自助建站如何快速打造专业网站?  深圳网站制作设计招聘,关于服装设计的流行趋势,哪里的资料比较全面?  网站制作哪家好,cc、.co、.cm哪个域名更适合做网站?  如何挑选最适合建站的高性能VPS主机?  如何在IIS中新建站点并解决端口绑定冲突?  如何通过cPanel快速搭建网站?  香港服务器网站搭建教程-电商部署、配置优化与安全稳定指南  制作证书网站有哪些,全国城建培训中心证书查询官网?  如何挑选优质建站一级代理提升网站排名?  建站之星收费标准详解:套餐费用及年费价格表一览  如何用搬瓦工VPS快速搭建个人网站?  如何通过远程VPS快速搭建个人网站?  建站主机解析:虚拟主机配置与服务器选择指南  建站之星代理如何优化在线客服效率?  GML (Geography Markup Language)是什么,它如何用XML来表示地理空间信息?  建站VPS推荐:2025年高性能服务器配置指南  邀请函制作网站有哪些,有没有做年会邀请函的网站啊?在线制作,模板很多的那种?  建站之家VIP精选网站模板与SEO优化教程整合指南  宝塔新建站点报错如何解决?  黑客如何利用漏洞与弱口令入侵网站服务器?  如何选择高效便捷的WAP商城建站系统?  详解免费开源的DotNet二维码操作组件ThoughtWorks.QRCode(.NET组件介绍之四)  如何通过IIS搭建网站并配置访问权限?  如何通过PHP快速构建高效问答网站功能?  建站之星微信建站一键生成小程序+多端营销系统  小程序网站制作需要准备什么资料,如何制作小程序?  建站之星如何优化SEO以实现高效排名?  免费网站制作模板下载,除了易企秀之外还有什么H5平台可以制作H5长页面,最好是免费的?  教程网站设计制作软件,怎么创建自己的一个网站?  手机钓鱼网站怎么制作视频,怎样拦截钓鱼网站。怎么办?  网站设计制作企业有哪些,抖音官网主页怎么设置?  如何在阿里云通过域名搭建网站?  h5在线制作网站电脑版下载,h5网页制作软件?  如何选择美橙互联多站合一建站方案?  模具网站制作流程,如何找模具客户?  网站视频怎么制作,哪个网站可以免费收看好莱坞经典大片?  专业的网站制作设计是什么,如何制作一个企业网站,建设网站的基本步骤有哪些?  网站制作企业,网站的banner和导航栏是指什么?  如何配置FTP站点权限与安全设置?  如何在云服务器上快速搭建个人网站?  C++如何将C风格字符串(char*)转换为std::string?(代码示例)  怀化网站制作公司,怀化新生儿上户网上办理流程?  如何通过宝塔面板实现本地网站访问?  视频网站制作教程,怎么样制作优酷网的小视频?  建站VPS能否同时实现高效与安全翻墙?  C#如何序列化对象为XML XmlSerializer用法  Swift中循环语句中的转移语句 break 和 continue  香港服务器部署网站为何提示未备案?  专业型网站制作公司有哪些,我设计专业的,谁给推荐几个设计师兼职类的网站? 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。