Linux作为server共享

Linux作为server共享到Linux/Windows

update: 2017.10

环境:

  • Ubuntu 14.04LTS / 16.04LTS, 作为server时假设IP为192.168.1.123
  • Windows 7 / Windows 10

参考: https://help.ubuntu.com/lts/serverguide/index.html

ssh

https://help.ubuntu.com/lts/serverguide/openssh-server.html
https://docs-old.fedoraproject.org/en-US/Fedora/24/html/System_Administrators_Guide/s2-ssh-configuration-sshd.html

  • ubuntu:
sudo apt-get install openssh-server
sudo systemctl restart sshd.service

客户端访问:

  • ubuntu: sudo apt-get install openssh-client
  • windows: xshell / FileZilla Client / ultraedit 等支持ssh/sftp

nfs

https://ubuntu.com/server/docs/service-nfs
https://help.ubuntu.com/lts/serverguide/network-file-system.html

  • Linux NFS server
sudo apt install nfs-kernel-server

vi /etc/exports  # 注意/etc/exports文件内容对whitespace敏感,所以不要乱加whitespace
/ubuntu  *(ro,sync,no_root_squash)
/home    *(rw,sync,no_root_squash)

sudo systemctl start nfs-kernel-server.service

showmount -e  # 查看
  • Linux作为客户端进行挂载
sudo apt install nfs-common

# mount server's /ubuntu目录 --> 本地的/local/ubuntu目录
mkdir -p /local/ubuntu  # The mount point directory must exist & empty
sudo mount example.hostname.com:/ubuntu /local/ubuntu
  • windows作为客户端进行挂载
    • 方法1
      资源管理器地址栏 \\192.168.1.123

    • 方法2
      https://technet.microsoft.com/en-us/library/cc754350(v=ws.11).aspx

      1. 控制面板->程序->打开或关闭windows功能->NFS客户端,勾选:NFS客户端
      2. win+R->cmd
      3. mount \\192.168.1.123\home\z\shareFolder X:
      4. umount X: 或 (umount -a 取消所有网络驱动器)
      

samba

参考:
https://ubuntu.com/server/docs/samba-file-server
https://help.ubuntu.com/lts/serverguide/samba-fileserver.html
http://blog.csdn.net/xiaoxinghehe/article/details/8294717

  1. 安装samba:**ubuntu: sudo apt-get install samba **

  2. 修改samba配置

    方法一:手动修改conf文件,参考samba-file-server

    $ sudo vi /etc/samba/smb.conf   #建议首先备份这个文件
    #1.修改[global]部分:
    workgroup = WORKGROUP  #根据workgroup/NT-domain name填写
    security = share     #共享模式 #若没有security这行,则省略之不用修改!
    
    #2.新添加一个section如下:
    [share]
    comment = share me
    path = /        #共享文件夹目录,比如根目录/
    browsable = yes
    guest ok = no
    read only = no
    create mask = 0644
    

    方法二:用界面直接配置
    参考 http://askubuntu.com/questions/785877/where-is-the-samba-configuration-gui-in-ubuntu-16-04/786542#786542

    在待分享的文件夹上鼠标右键 - 本地网络共享
    
  3. 添加samba用户
    在Ubuntu20.04LTS上验证,添加samba用户此步骤已经不再需要!

    $ #sudo smbpasswd -a `whoami` (即USERNAME你当前用户名)  #此步骤已不再需要
    
  4. 重启samba服务: service smbd restart(ubuntu) 或者 service smb restart(其他linux发行版) 或 重启电脑:

    sudo systemctl restart smbd.service nmbd.service
    

客户端:

  • windows: 资源管理器地址栏 \\192.168.1.123
  • Linux:
sudo apt-get install smbfs
sudo mount -o username=USERNAME //192.168.1.123/share local_mount_path/

virtual box的samba配置

virtual box Network:

  • Adapter1: 使用默认的NAT,用于访问网络
  • Adapter2: 使用Host-only Adapter。通过它的ip,让外面的Windows主机能够访问到virtual box里面的samba共享

vnc

参考: http://www.2cto.com/os/201507/422937.html

服务端

  • ubuntu 14.04~18.04:
    • (1).使用ubuntu自带的Desktop sharing, 打开共享
    • (2).安装和配置dconf-editor: sudo apt-get install dconf-editor
      • 运行dconf-editor. 注意一定要用当前用户来运行,不要加sudo.
      • 依次展开org->gnome->desktop->remote-access, 将"requre-encryption"去掉.

客户端:

  • Linux: remmina客户端
  • Windows: vnc viewer
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值