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).aspx1. 控制面板->程序->打开或关闭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
-
安装samba:**ubuntu:
sudo apt-get install samba
** -
修改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在待分享的文件夹上鼠标右键 - 本地网络共享
-
添加samba用户
在Ubuntu20.04LTS上验证,添加samba用户此步骤已经不再需要!$ #sudo smbpasswd -a `whoami` (即USERNAME你当前用户名) #此步骤已不再需要
-
重启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