无法创建目录/home/hadoop/.ssh:权限被拒绝?

rsaldnfx  于 2021-06-03  发布在  Hadoop
关注(0)|答案(4)|浏览(1005)

我正在ubuntu操作系统上配置hadoop。我需要创建rsa密钥对以允许hadoop与其节点交互,因此我运行以下命令:

hadoop@ubuntu:~$ ssh-keygen -t rsa -P ""

然后我得到这个:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
Could not create directory '/home/hadoop/.ssh': permission denied.
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
open /home/hadoop/.ssh/id_rsa failed: No such file or directory.
Saving the key failed: /home/hadoop/.ssh/id_rsa.
rryofs0p

rryofs0p1#

检查主目录名称和权限

echo $HOME
             cd ~ ; ls -l 
             ls -l .ssh
             ls -lR .ssh

如果上述输出正常,并且您拥有正确的权限,那么您的配额可能已满
试试“sudo”看看会发生什么。。。

ny6fqffe

ny6fqffe2#

似乎当前用户不拥有主目录下的内容。
取得所有权如下:

admin@mydb22-02:~$ sudo chown admin.admin /home/admin/
admin@mydb22-02:~$ ls -la
total 32
drwxr-xr-x 2 admin admin 4096 Nov  3 23:29 .
drwxr-xr-x 3 admin admin 4096 Dec 23  2012 ..
-rw------- 1 admin admin  191 Feb 13  2013 .bash_history
-rw-r--r-- 1 admin admin  220 Apr  3  2012 .bash_logout
-rw-r--r-- 1 admin admin 3486 Apr  3  2012 .bashrc
-rw-r--r-- 1 admin admin  675 Apr  3  2012 .profile
-rw-r--r-- 1 admin admin    0 Nov  3 23:29 .sudo_as_admin_successful
-rw------- 1 admin admin 4221 Nov  3 20:31 .viminfo

生成密钥的工作方式是:生成非对称密钥后,当前用户将创建并拥有ssh目录

kcugc4gi

kcugc4gi3#

I have spent arround 1 hr on this and finally got the solution. It is due to permission problem. You have to use chown for your 'hadoop user'.

1. First make hadoop directory.
cd /home 
mkdir hadoop
then check 'ls -l'. it gives result like :
drwxr-xr-x  2 hadoop hadoop 4096 Aug 22 22:17 hadoop

2. sudo chown hadoop.hadoop /home/hadoop/
3. Then run remaining command for key generater.
yxyvkwin

yxyvkwin4#

忘记创建 .ssh 在你家吗?
试试看:

mkdir -p ~/.ssh

然后重新运行ssh-keygen。
也可能是您从错误的用户创建ssh密钥。。是你用sudo启动的?
尝试手动设置home dir或在提示符下输入right path。

相关问题