关于Linux和windows之间linux 挂载 权限权限以及SFTP的一个问题。

114网址导航网页设计教程与开发
提供各种常见网页效果
提供各种各样的设计教程
装扮QQ,让QQ变得更酷
设计参考,提高自升水平
学习服务器和操作系统
提供各种素材和工具
收藏学习资料
您现在的位置:&&>>&&>>&&>>&正文
Linux下SFTP用户权限设置条件及实现命令
众所周知SFTP账号是基于SSH账号的,所以在默认情况下访问服务器的权限是非常大的,今天的教程就是教大家进行SFTP用户权限设置。必要条件: 你的openssh-server版本至少得失4.8p1, 因为配置权限需要版本添加的新配置项ChrootDirectory来完成。 如何查看自己服务器上的ssh版本?大家可以尝试以下命令: $ ssh -V 具体实施步骤: 1. 我们需要创建一个用户组,专门用于sftp用户 $ groupadd sftpusers 2. 我们创建一个用户test $ useradd -s /bin/false -G sftpuser test 注意这里我们将test用户的shell设置为/bin/false使他没有登陆shell的权限 3. 编辑 /etc/ssh/sshd_config 找到Subsystem这个配置项,将其修改为 Subsystem sftp internal-sftp 然后再到文件最尾处增加配置设定属于用户组sftpusers的用户都只能访问他们自己的home文件夹 Match Group sftpusers ChrootDirectory %h ForceCommand internal-sftp AllowTcpForwarding no 保存并关闭文件 4. 修改test用户home文件夹的权限,让其属于root用户 chown root ~test 5. 重启sshd服务 $ service sshd restart 6. 测试用户账号 $ ssh test@localhost 连接会被拒绝或者无法登陆 $ sftp tesst@localhost 登陆后你会发现你的账号无法切换到除自己home目录之外的地方的 常见问题: 如果你链接服务器的时候出现下面的提示: Write failed: Broken pipe Couldn't read packet: Connection reset by peer 这个问题的原因是ChrootDirectory的权限问题,你设定的目录必须是root用户所有,否则就会出现问题。所以请确保sftp用户根目录的所有人是root, 权限是 750 或者 755。
转载请注明:破洛洛(谢谢合作)
上一篇文章: 下一篇文章:
网友评论:主题信息(必填)
主题描述(最多限制在50个字符)
申请人信息(必填)
申请信息已提交审核,请注意查收邮件,我们会尽快给您反馈。
如有疑问,请联系
分享是件奇怪的东西绝不因为你分给了别人而减少有时你分给别人的越多自己得到的也越多
如果你想成功你不应该成为一个普通的可被随意替代的人你应该成为稀缺的不可替代的那类人
创建自己的SFTP服务器的方法其实很简单。
SFTP是什么?和FTP有什么不同?
FTP(File Transport Protocol)最早是发明于1971年,最初是通过NCP(Network Control Protocol)来传送文件,进行了版本升级后,支持了TCP/IP和IPv6。
像FTP一样,SFTP(Secure File Transport Protocol)也是用于传送文件,但基础技术更加安全。SFTP实现了SSH(Secure Shell)协议,使得使用加密传输认证信息和传输的数据,也就是说数据不以FTP那样以明文方式传送。这也意味着,SFTP和FTP是不兼容的。
如果谁想把一台机器迁到一个文件服务器上,显然SFTP比FTP更可取。所以,下面会提供给你一些方法。
Mac OS X机器:
在OS X Mavericks系统选项里选择Sharing,点击Remote Login复选框然后选择All users。
此时,SFTP服务器是可以运行了,当测试服务器来自一台不同机器,IP地址会显示在Sharing窗口。我用了来验证Mac的SFTP服务器是否能正常运行。
Linux机器:
大多数的Linux发行版都可以设置自动启动SSH。
在Slackware可以通过下面的命令实现快速的实现:/etc/ssh/sshd_config | grep "Subsystem"
使用pico来编辑sshd_config文件,之后使用下面命令来重启sshd:/etc/rc.d/rc.sshd stop
/etc/rc.d/rc.sshd start
Windows机器
推荐msftpsrvr工具,免费下载:。
使用时,运行已经下载的文件,输入相关登录信息以及设置文件存储路径。
Windows下的SFTP客户端软件也还有或CoreFTP的工具。
英文原文:
极客头条正式开通了微信公众号,在微信搜索“csdn_geek”或扫描下方的二维码即可关注。博客访问: 63858
博文数量: 5
注册时间:
各类IT技术。
ITPUB论坛APP
ITPUB论坛APP
APP发帖 享双倍积分
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: Linux
针对redhat 6.3系统。
通过linux 的mount命令挂载windows下的共享目录,挂载后目录权限为755,普通用户没有权限写入。
[root@lccwyy ~]# mount -t cifs //192.168.50.34/temp /root/aa -o username=allenli,password=lcc201314,rw,
[root@lccwyy ~]# ls -l | grep aa
drwxr-xr-x. 1 root root
[root@lccwyy ~]#
chmod给目录加权限出现错误,和普通的目录不同。
[root@lccwyy ~]# chmod 777 aa
chmod: changing permissions of `aa&: Permission denied
通过linux的 man mount.cifs 简单的了解下。
& & & &mount.cifs - mount using the Common Internet File System (CIFS)
& & & &cifs的意思是通用网络文件系统。
DESCRIPTION
& & & &This tool is part of the cifs-utils suite.
& & & &mount.cifs mounts a Linux CIFS filesystem. It is usually invoked indirectly by the mount(8) command when using the "-t cifs" option. This command only works in&Linux, and the kernel must support the cifs filesystem. The CIFS protocol is the successor to the SMB protocol and is supported by most Windows servers and many&other commercial servers and Network Attached Storage appliances as well as by the popular Open Source server Samba.
& &&& mount.cifs用于挂载linux的CIFS文件系统,当用-t cifs命令的时候间接的涉及了mount(8)命令。这个命令只能在linux上执行,以及内核必须支持cifs文件系统。cifs协议的前身是smb协议,被大部分的windows、商业服务器、存储应用支持。(mount.cifs跟mount -t cifs唯一的区别就是mount.cifs在samba软件包里,而mount在util-linux软件包里。)
& & & &The mount.cifs utility attaches the UNC name (exported network resource) specified as service (using //server/share syntax, where "server" is the server name or IP&address and "share" is the name of the share) to the local directory mount-point.
& & & &mount&-t&cifs&192.168.50.34:temp /root/aa 通过类似的形式使用。192.168.50.34是windows的ip地址,temp目录是windows的共享目录。
& & & &Options to mount.cifs are specified as a comma-separated list of key=value pairs. It is possible to send options other than those listed here, assuming that the&cifs filesystem kernel module (cifs.ko) supports them. Unrecognized cifs mount options passed to the cifs vfs kernel code will be logged to the kernel log.
& & & &mount.cifs causes the cifs vfs to launch a thread named cifsd. After mounting it keeps running until the mounted resource is unmounted (usually via the umount&utility).
& & & & &mount.cifs 挂载后会有一个cifsd进程出现。
继续查看下mount.cifs的语法。
file_mode=arg
&If the server does not support the CIFS Unix extensions this overrides the default file mode.
dir_mode=arg
If the server does not support the CIFS Unix extensions this overrides the default mode for directories.
可以通过file_mode 和dir_mode 来设置权限,覆盖默认的755权限。
[root@lccwyy ~]# mount -t cifs //192.168.50.34/temp /root/aa -o username=allenli,password=lcc201314,rw,dir_mode=0777,file_mode=0777
[root@lccwyy ~]# ls -l | grep aa
drwxrwxrwx. 1 root root
[root@lccwyy ~]#
阅读(13785) | 评论(1) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
这样设置以后,不知道为什么SFTP访问的用户都不能访问了!
请登录后评论。}

我要回帖

更多关于 windows sftp 到linux 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信