sshfs远程挂载
1 2 3 4 5 | #常用命令 sshfs - o nonempty,reconnect,allow_other, exec - p22 zjy@ 172.21 . 0.10 : / data / zjy / data / zjy cat / etc / fstab sshfs #zjy@172.21.0.10:/data/zjy /data/zjy fuse nonempty,reconnect,allow_other,exec 0 0 |
一、什么是 SSHFS
SSHFS(Secure SHell FileSystem)是一个客户端,可以让我们通过 SSH 文件传输协议(SFTP)挂载远程的文件系统并且在本地机器上和远程的目录和文件进行交互。
1 2 3 4 5 | centos: yum install sshfs ubuntu: sudo apt - get install sshfs |
二、准备两台任意操作系统
1 2 3 4 5 | 一台 mkdir / test / zjy / 另一台 mkdir / test / zjy / |
三、挂载
1 2 | sudo sshfs - o nonempty,allow_other, exec root@xx.xx.xx.xx: / test / zjy / / test / zjy / 参数 用户@地址:挂载到 挂载到 |
nonempty 允许安装在非空文件/DIR上
allow_other 允许访问其他用户
mount -a 重新加载挂载信息
四、查看
1 2 3 4 5 6 7 8 9 10 11 12 13 | 查看当前系统挂载: [root@xiaoyuer ~] # cat /etc/mtab / dev / vda1 / ext3 rw,noatime,acl,user_xattr 0 0 proc / proc proc rw 0 0 sysfs / sys sysfs rw 0 0 devpts / dev / pts devpts rw,mode = 0620 ,gid = 5 0 0 none / proc / sys / fs / binfmt_misc binfmt_misc rw 0 0 root@ 192.168 . 1.121 : / test / / test / zjy fuse.sshfs rw,nosuid,nodev,allow_other 0 0 添加到自动挂载: root@ 192.168 . 1.121 : / test / / test / zjy fuse.sshfs rw,nosuid,nodev,allow_other 0 0 |
五、卸载命令
1 | umount - f / test / zjy / |
六、如果想免秘钥(可以做ssh免秘钥)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 1.ssh 免秘钥登录 / 挂载: ssh - keygen - t rsa [root@xiaoyuer ~] # ssh-keygen -t rsa 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 : b0: 9d : 41 : 56 :b5:c4:b2: 0e : 0d : 47 : 07 : 4d :fa: 4c : 47 : 03 root@xiaoyuer The key's randomart image is : + - - [ RSA 2048 ] - - - - + | oo + * E.o | | o. o + oo . | | . . + .oo . | | + .oo + . | | . So o | | . | | | | | | | + - - - - - - - - - - - - - - - - - + 2. 把公钥复制到服务器上 ssh - copy - id - i ~ / .ssh / id_rsa.pub root@xx.xx.xx.xx [root@xiaoyuer ~] # ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.121 root@ 192.168 . 1.121 's password: Now try logging into the machine, with "ssh 'root@192.168.1.121'" , and check in : .ssh / authorized_keys to make sure we haven 't added extra keys that you weren' t expecting. 3. 测试 [root@xiaoyuer ~] # ssh root@xx.xx.xx.xx 测试成功在挂载就不需要数据密码<em id = "__mceDel" style = "background-color: rgba(255, 255, 255, 1); font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px" > < / em> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构