Remote Disk Mount
⚠️ Security Note: This skill is for Debian/Ubuntu Linux only. Do NOT use on other OS without adaptation.
⚠️ Security Guidelines
- 1. Never pass passwords on command line — Use credential files or interactive prompts instead
- Confirm with user before running sudo commands — Don't auto-execute privileged operations
- Use SSH keys for SFTP — Avoid password-based authentication
- Mount untrusted storage with caution — It can expose local files
🚀 Workflow
Step 1: Collect Info (Ask User)
Ask the user for:
- - Protocol: SMB / FTP / SFTP / WebDAV?
- Server IP/hostname: e.g.,
192.168.1.100 or INLINECODE1 - Username: (for SMB/FTP/SFTP)
- Password: (will be used interactively, never shown in commands)
- Share name: (for SMB only, e.g.,
shared) - Mount point name: (optional, e.g.,
nas, backup)
💡 Tip: Ask one question at a time, wait for response. Don't assume any values.
Step 2: Check Environment
Run this to check/install deps based on protocol:
CODEBLOCK0
Step 3: Create Mount Point
CODEBLOCK1
Protocol Details
SMB/CIFS
Credential file method:
CODEBLOCK2
FTP (curlftpfs)
Interactive password (recommended):
CODEBLOCK3
SFTP (SSHFS)
Key-based auth (recommended):
CODEBLOCK4
WebDAV
CODEBLOCK5
Unmount
CODEBLOCK6
Checklist Before Running
- - [ ] Confirm OS is Debian/Ubuntu
- [ ] Get user confirmation before sudo commands
- [ ] Verify remote server is trusted
- [ ] Use SSH keys for SFTP instead of passwords
- [ ] Delete credential files after use if sensitive
远程磁盘挂载
⚠️ 安全提示:此技能仅适用于 Debian/Ubuntu Linux 系统。未经适配请勿在其他操作系统上使用。
⚠️ 安全指南
- 1. 切勿在命令行中传递密码 — 应使用凭据文件或交互式提示代替
- 执行sudo命令前需征得用户确认 — 不要自动执行特权操作
- SFTP使用SSH密钥 — 避免基于密码的身份验证
- 谨慎挂载不受信任的存储 — 可能暴露本地文件
🚀 工作流程
步骤1:收集信息(询问用户)
向用户询问:
- - 协议:SMB / FTP / SFTP / WebDAV?
- 服务器IP/主机名:例如 192.168.1.100 或 nas.example.com
- 用户名:(用于SMB/FTP/SFTP)
- 密码:(将交互式使用,绝不在命令中显示)
- 共享名称:(仅SMB需要,例如 shared)
- 挂载点名称:(可选,例如 nas、backup)
💡 提示:每次只问一个问题,等待回复。不要假设任何值。
步骤2:检查环境
根据协议运行以下命令检查/安装依赖:
bash
SMB
sudo apt install smbclient cifs-utils -y
FTP
sudo apt install curlftpfs -y
SFTP
sudo apt install sshfs -y
WebDAV
sudo apt install cadaver davfs2 -y
步骤3:创建挂载点
bash
mkdir -p ~/mount_<名称>
协议详情
SMB/CIFS
凭据文件方法:
bash
1. 创建凭据文件
echo username=$USERNAME | sudo tee /root/.smbcredentials
echo password=$PASSWORD | sudo tee -a /root/.smbcredentials
sudo chmod 600 /root/.smbcredentials
2. 挂载
sudo mount.cifs //服务器IP/共享 ~/挂载点名称 -o credentials=/root/.smbcredentials,uid=1000,gid=1000
FTP (curlftpfs)
交互式密码(推荐):
bash
curlftpfs -o user=$USERNAME ftp://服务器IP/ ~/挂载点名称
密码将通过交互式提示输入 - 绝不在命令中显示
SFTP (SSHFS)
基于密钥的身份验证(推荐):
bash
sshfs $USERNAME@服务器IP:/ ~/挂载点名称 -o uid=1000,gid=1000
使用 -o identityfile=~/.ssh/id_rsa 进行基于密钥的身份验证
WebDAV
bash
sudo mount -t davfs http://服务器IP/webdav /mnt/webdav -o uid=1000,gid=1000
密码通过交互式提示输入
卸载
bash
sudo umount /挂载点
或针对FUSE
sudo fusermount -u /挂载点
执行前检查清单
- - [ ] 确认操作系统为Debian/Ubuntu
- [ ] 执行sudo命令前获取用户确认
- [ ] 验证远程服务器可信
- [ ] SFTP使用SSH密钥而非密码
- [ ] 使用后删除敏感凭据文件