1.nfs:虚拟机桥接模式下,开发板和虚拟机保持在同一网段下,开发板不要直连电脑
挂载命令:mount -v -t nfs 192.168.110.154:/home/lhj /mnt -o nolock
(1) 安装 NFS 服务器
sudo apt update
sudo apt install nfs-kernel-server -y
(2) 创建共享目录并设置权限
sudo mkdir -p /mnt/nfs_share
sudo chown nobody:nogroup /mnt/nfs_ # 修改所有权 注意共享文件夹路径为/mnt/nfs
sudo chmod 777 /mnt/nfs_ # 开放读写权限(测试用,生产环境需限制)
(3) 配置 NFS 共享
sudo vi /etc/exports
添加以下内容(允许所有客户端访问):
/mnt/nfs_*(rw,sync,no-subtree-check,no-root-squash)注意-是下划线!!!!!!
检查是否有语法错误sudo exportfs -rv
(4) 生效配置并启动服务
sudo exportfs -a # 重新加载配置
sudo systemctl restart nfs-kernel-server # 重启服务
sudo systemctl enable nfs-kernel-server # 开机自启
sudo systemctl status nfs-kernel-server
或
重启:sudo service nfs-kernel-server status
重启:sudo service nfs-kernel-server restart
(5) 检查 NFS 共享是否发布成功
showmount -e localhost
输出应显示:
Export list for localhost:
/mnt/nfs_share *
- 在客户端挂载 NFS 共享
(1) 客户端安装 NFS 工具
sudo apt update
sudo apt install nfs-common -y
(2) 创建本地挂载点
sudo mkdir -p /mnt/nfs_client
(3) 手动挂载 NFS 共享
sudo mount -t nfs <虚拟机IP>:/mnt/nfs_share /mnt/nfs_client
/home/lhj 192.168.110.113/24(rw,sync,no_root_squash,no_subtree_check)
- 设置开机自动挂载
sudo nano /etc/fstab
<虚拟机IP>:/mnt/nfs_share /mnt/nfs_client nfs defaults 0 0
2.samba
sudo vi /etc/samba/smb.conf
sudo systemctl restart smbd nmbd
sudo systemctl status smbd nmbd
I
3.ssh
sudo vi /etc/ssh/sshd_config
sudo systemctl status ssh
sudo systemctl restart ssh 通过这个命令重启
设置
PasswordAuthentication yes # 如果使用密码登录
或
PubkeyAuthentication yes # 如果使用密钥登录
4.切换root账号
su -或者 su root
4.1 以 root 用户身份启动一个交互式 shell,并加载 root 用户的环境变量:sudo -i 更推荐
4.2 su:切换到 root 用户(需要输入 root 用户的密码)。
4.3 sudo su:使用当前用户的 sudo 权限来运行 su 命令,从而切换到 root 用户(需要输入当前用户的密码,而不是 root 用户的密码)。
root@ubuntu:/home/lhj# ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:7T472hTUAv7hb894x4bocVbgcX7hhcP+2fPL3WkOMkI [email protected]
The key's randomart image is:
+---[RSA 4096]----+
| . |
| . . . . . |
| . + . *.o|
| = o o.*o|
| SE= o.+|
| .. o o+|
| .oo+oo=o|
| ++.+B=.X|
| ..+=o.=B=|
+----[SHA256]-----+