前提准备
sudo ufw disable
sudo ufw status
sudo apt update
ssh服务
sudo apt-get install openssh-server
sudo apt-get install openssh-client
sudo apt-get install ssh
echo "PasswordAuthentication yes" >> /etc/ssh/ssh_config //配置ssh客户端
echo "PermitRootLogin yes">>/etc/ssh/sshd_config //配置ssh服务器端
systemctl restart sshd
service ssh restart
sudo systemctl status ssh
ssh root@192.168.x.xxx //验证ssh连接
注意:客户端和服务器端最好都把上面这些操作一遍
samba服务
sudo apt install samba samba-common
sudo mkdir -p /tftpboot /mnt
sudo chmod 777 /tftpboot /mnt
把下面这些内容复制并添加到/etc/samba/smb.conf文件里
[tftpboot]
comment = tftpboot folder
browseable = yes
path = /tftpboot
force user = root
force group = root
public = yes
available = yes
writable = yes
guest ok = yes
available = yes
[mnt]
comment = mnt
browseable = yes
path = /mnt
force user = root
force group = root
public = yes
available = yes
writable = yes
guest ok = yes
available = yes
[root]
#说明
comment = / floder
#共享的 samba 目录
path = /
#允许访问
available = yes
#可以浏览
browseable = yes
#公开
public = yes
#可写
writable = yes
read only = no
guest ok = yes
#当外部创建新文件时的权限
create mask = 0755
#共享模式,不用密码可以登陆
security = share
#在外部添加新文件时,文件的所有者
force user = root
sudo service smbd restart
sudo service smbd status
然后在windows端打开开发板/ubuntu的网络文件夹地址,测试看一下是不是已经可以成功打开,如果成功,结果应该如下图所示:
tftp服务
sudo apt install tftpd-hpa
sudo chmod 777 /etc/default/tftpd-hpa
echo -e '# /etc/default/tftpd-hpa\n\nTFTP_USERNAME="tftp"\nTFTP_DIRECTORY="/tftpboot"\nTFTP_ADDRESS="0.0.0.0:69"\nTFTP_OPTIONS="-c -l -s"' | sudo tee /etc/default/tftpd-hpa > /dev/null
sudo systemctl restart tftpd-hpa
sudo systemctl status tftpd-hpa
经上面设置后,/tftpboot为服务器地址,客户端get的文件都会从这个目录下寻找,请保证客户端想要get的内容在tftpboot目录下是存在的,并保证文件权限
测试tftp功能:
nfs服务
sudo apt-get install nfs-kernel-server nfs-common
echo "/ *(rw,sync,no_root_squash,no_subtree_check)" >> /etc/exports
rw
:表示允许读写访问。sync
:确保数据同步到磁盘后再响应客户端请求。no_subtree_check
:关闭子目录检查,提高性能。
以上配置将/目录设置为nfs共享目录
sudo exportfs -ra //重新加载nfs配置
sudo systemctl start nfs-kernel-server
sudo systemctl enable nfs-kernel-server
sudo exportfs -a
sudo exportfs -v //检查nfs配置是否成功
showmount -e
验证nfs服务:
在客户端执行以下操作
sudo mkdir -p /mnt
sudo mount -t nfs -o nolock <NFS服务器IP>:/ /mnt
将服务器的/目录挂载到客户端的/mnt目录下,当客户端成功后,客户端进入到/mnt目录就相当于进入到服务器的/目录,如果服务器端根目录下内容很多,可能挂载命令会持续的比较久,耐心等待一下