Ubuntu 20.04.3 部署NAS

Ubuntu 20.04.3 部署NAS,第1张

Ubuntu 20.04.3 部署NAS

Ubuntu 20.04.3 LTS 部署NAS

1.硬件配置2.Ubuntu 20.04.3 镜像下载3.更新国内镜像源(清华、中科大、阿里、网易)4.安装系列软件

4.1 ssh远程登陆软件4.2 安装vim软件4.3 安装Samba 5.设置防火墙

1.硬件配置

矿渣蜗牛星际C款,J1900 ,2GB内存,120GB固态硬盘,两个4TB西数机械硬盘。
16GB的U盘、鼠标、键盘(有线)(安装镜像使用)

2.Ubuntu 20.04.3 镜像下载

1.访问官网https://cn.ubuntu.com/download/desktop下载官方镜像。
2.使用balenaEtcher软件,将下载的镜像写入U盘中。
3.长按开机按钮,待指示灯亮起时,依旧按着开机按钮,此时机器会自动关闭,然后再短按开机按钮,将键盘插入机器中,长按住F7按键,选择U盘启动,然后安装Ubuntu系统。

3.更新国内镜像源(清华、中科大、阿里、网易)

sudo vim /etc/apt/sources.list

#阿里源
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    #网易源
    deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
    #清华源
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    ##中科大源
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

sudo apt-get update
sudo apt-get upgrade

4.安装系列软件 4.1 ssh远程登陆软件

安装openssh-server

sudo apt-get install openssh-server

开机自动启动ssh命令

sudo systemctl enable ssh

关闭ssh开机自动启动命令

sudo systemctl disable ssh

单次开启ssh

sudo systemctl start ssh

单次关闭ssh

sudo systemctl stop ssh

重启ssh

- sudo service ssh restart  

查看ssh是否启动,看到Active: active (running)即表示成功

sudo systemctl status ssh

设置防火墙

sudo ufw allow ssh
4.2 安装vim软件
sudo apt-get install vim
4.3 安装Samba

samba的安装:

sudo apt-get insall samba

创建用户
客户端通过samba进行认证的用户必须首先是Linux系统中的用户, 不过不用配置密码, 密码用专门的smbpasswd命令进行设置

sudo useradd sbuser
sudo smbpasswd -a sbuser

创建要共享的文件夹

 sudo mkdir /home/shared

修改文件夹的所有者与上面新建的用户一致, 否则会导致没有权限进行访问

 sudo chown sbuser /home/shared

配置samba

sudo vim /etc/samba/smb.conf

在配置文件末尾添加下面内容:

[NAS_000]
	comment = This is shared folder.
	path = /home/shared
	read only = no
	browsable = yes

注意这里中括号中间的名称即为后面客户端访问时IP地址/后面的名称

在smb.conf中[global]中加入(防止乱码)

display charset = UTF-8
unix charset = UTF-8
dos charset = cp936

接下来我们需要用这个命令启动Samba服务。

sudo service smbd restart

添加防火墙(二选一,作者选择的第二种)

# samba属于firewalld内置的服务, 可以直接加
sudo firewall-cmd --add-service=samba

#更新防火墙规则
#我们需要更新防火墙规则,通过发布这个命令来允许这个服务。
sudo ufw allow samba

然后就可以再windows系统上执行win+R 在d出框里输入:蜗牛星际的IP地址NAS_000 回车然后输入用户名和密码即可访问共享文件夹了。 5.设置防火墙

sudo ufw enable
sudo ufw status
你可以使用以下命令轻松地通过端口号允许和拒绝连接:
sudo ufw allow 80 <== 允许 http 访问
sudo ufw deny 25 <== 拒绝 smtp 访问

参考文章
https://www.jianshu.com/p/b9fab528dd6b
https://blog.csdn.net/lpwmm/article/details/116664479
https://www.cnblogs.com/a5idc/p/13850760.html
https://blog.csdn.net/gorunbu/article/details/44706793

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5704684.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存