Hadoop安全之hftp
hftp默认是打开的,允许以浏览器的方式访问和下载文件,以此方式下,可以读取所有文件,留下了安全隐患.
测试如下
/user/hive/warehouse/cdntest.db/selfreadonly/hosts的上级目录selfreadonly的所有者是zhouyang,权限是700,但以linuxidc用户在浏览器中输入以下地址,就能下载.
http://localhost:50070/webhdfs/v1/user/hive/warehouse/cdntest.db/selfreadonly/hosts?op=OPEN&offset=0&length=1024
在hdfs-site.xml中添加以下配置禁用webhdfs
<property>
<name>dfs.webhdfs.enabled</name>
<value>false</value>
</property>
禁止webhdfs之后,hftp协议可以继续使用.测试如下:
[linuxidc@localhost ~]$ Hadoop fs -ls hftp://localhost:50070/user/hive/warehouse/cdntest.db/selfreadonly
ls: user=linuxidc, access=READ_EXECUTE, inode="/user/hive/warehouse/cdntest.db/selfreadonly":zhouyang:cdn:drwx------
[linuxidc@localhost ~]$ hadoop fs -ls hftp://localhost:50070/user/hive/warehouse/cdntest.db
Found 4 items
drwx------ - zhouyang cdn 0 2015-06-04 10:40 hftp://localhost:50070/user/hive/warehouse/cdntest.db/selfreadonly
drwxrwxr-x - wangjing cdn 0 2015-06-02 18:51 hftp://localhost:50070/user/hive/warehouse/cdntest.db/testp1
drwxrwx--- - cdn cdn 0 2015-06-03 17:37 hftp://localhost:50070/user/hive/warehouse/cdntest.db/testp2
drwxrwxr-x - wangjing cdn 0 2015-06-02 10:17 hftp://localhost:50070/user/hive/warehouse/cdntest.db/wangjing
/user/hive/warehouse/cdntest.db/selfreadonly/hosts的上级目录selfreadonly的所有者是zhouyang,权限是700,但以linuxidc用户在浏览器中输入以下地址,就能下载.
http://localhost:50070/webhdfs/v1/user/hive/warehouse/cdntest.db/selfreadonly/hosts?op=OPEN&offset=0&length=1024
禁止webhdfs之后,hftp协议可以继续使用.
[linuxidc@localhost ~]$ hadoop fs -ls hftp://localhost:50070/user/hive/warehouse/cdntest.db/selfreadonly
ls: user=linuxidc, access=READ_EXECUTE, inode="/user/hive/warehouse/cdntest.db/selfreadonly":zhouyang:cdn:drwx------
[linuxidc@localhost ~]$ hadoop fs -ls hftp://localhost:50070/user/hive/warehouse/cdntest.db
Found 4 items
drwx------ - zhouyang cdn 0 2015-06-04 10:40 hftp://localhost:50070/user/hive/warehouse/cdntest.db/selfreadonly
drwxrwxr-x - wangjing cdn 0 2015-06-02 18:51 hftp://localhost:50070/user/hive/warehouse/cdntest.db/testp1
drwxrwx--- - cdn cdn 0 2015-06-03 17:37 hftp://localhost:50070/user/hive/warehouse/cdntest.db/testp2
drwxrwxr-x - wangjing cdn 0 2015-06-02 10:17 hftp://localhost:50070/user/hive/warehouse/cdntest.db/wangjing