ssh连接无法工作

zpgglvta  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(372)

我是hadoop新手。正在尝试通过ssh连接namenode和data node。但我不能访问ssh没有密码,即使我有设置公钥
下面是sshd配置。


# Package generated configuration file

# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for

Port 22

# Use these options to restrict which interfaces/protocols sshd will bind to

# ListenAddress ::

# ListenAddress 0.0.0.0

Protocol 2

# HostKeys for protocol version 2

HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Privilege Separation is turned on for security

UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key

KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging

SyslogFacility AUTH
LogLevel INFO

# Authentication:

LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes

# AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files

IgnoreRhosts yes

# For this to work you will also need host keys in /etc/ssh_known_hosts

RhostsRSAAuthentication no

# similar for protocol version 2

HostbasedAuthentication no

# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication

# IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)

PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with

# some PAM modules and threads)

ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords

# PasswordAuthentication yes

# Kerberos options

# KerberosAuthentication no

# KerberosGetAFSToken no

# KerberosOrLocalPasswd yes

# KerberosTicketCleanup yes

# GSSAPI options

# GSSAPIAuthentication no

# GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes

# UseLogin no

# MaxStartups 10:30:60

# Banner /etc/issue.net

# Allow client to pass locale environment variables

AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,

# and session processing. If this is enabled, PAM authentication will

# be allowed through the ChallengeResponseAuthentication and

# PasswordAuthentication.  Depending on your PAM configuration,

# PAM authentication via ChallengeResponseAuthentication may bypass

# the setting of "PermitRootLogin without-password".

# If you just want the PAM account and session checks to run without

# PAM authentication, then enable this but set PasswordAuthentication

# and ChallengeResponseAuthentication to 'no'.

UsePAM yes

请告诉我如何解决这个问题。我在谷歌上尝试过几种可用的解决方案,但没有一种是有效的。请帮忙

t3psigkw

t3psigkw1#

试着遵循以下步骤。
更改为根用户

arif@ubuntu:~$sudo -s

重新创建ssh目录

root@ubuntu:~# cd ~

root@ubuntu:/# sudo rm -rf .ssh
root@ubuntu:/# ls -l .ssh
ls: cannot access .ssh: No such file or directory
root@ubuntu:/# mkdir .ssh
root@ubuntu:/# chmod 700 .ssh

创建授权的密钥文件

root@ubuntu:/# touch .ssh/authorized_keys
root@ubuntu:/# chmod 600 .ssh/authorized_keys

生成无密码密钥

root@ubuntu:/# ssh-keygen -t rsa -P ""
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
4f:f1:83:ad:03:ed:82:46:fa:11:ec:74:10:bf:03:41 root@ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
|     .E          |
|       +         |
|      o . .      |
|     . o o =     |
|      = S + +    |
|     = + * . .   |
|    . = . =      |
|     o . . .     |
|      .          |
+-----------------+

将该密钥复制到其他服务器
另外,复制到localhost

root@ubuntu:/# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
root@ubuntu:/# chmod -R 750 /root/.ssh/authorized_keys

测试你的钥匙

root@ubuntu:/# ssh localhost
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
87:21:89:ac:cd:ce:bf:32:30:d6:d2:a2:dc:ff:6d:ad.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:1
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R localhost
ECDSA host key for localhost has changed and you have requested strict checking.
Host key verification failed.

按照上面提到的说明出错

root@ubuntu:/# ssh-keygen -f "/root/.ssh/known_hosts" -R localhost

# Host localhost found: line 1 type ECDSA

/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old

再次测试

root@ubuntu:/# ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 87:21:89:ac:cd:ce:bf:32:30:d6:d2:a2:dc:ff:6d:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-31-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

New release '16.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Wed Dec 20 07:13:15 2017 from localhost

现在,启动hadoop

root@ubuntu:/# cd $HADOOP_HOME
root@ubuntu:~/applications/hadoop/hadoop-2.9.0# sbin/start-all.sh

现在一定要用
sudo -s root user login ,然后启动hadoop集群 sbin/start-all 或者 sbin/stop-all ,否则您必须先提到是,然后再提供五次密码。

相关问题