How to mount a remote directory in Linux using sshfs
Q. I have access rights to one of the remote server through SSH protocol and there is no File share services such as Samba, NFS or FTP etc which are enabled on the server. Now I want to mount data from that remote server, is it possible to mount remote folders?
A. The answer to this is yes, We can share data/mount folder on a local machine by using just SSH protocol. This can be done by using FUSE(Filesystem in USErspace) whichsupport SSH and FTP file systems. This post is in response to conversation which I had with one our users two days back. the question he asked about ftp is “I want to transfer one latest file from my ftp server and I want to automate this task through shell script to download latest file from my FTP server, And I don’t know what is the Operating System at server end(This is ultimate sentence I hear from the user today in my office )“. Let’s prepare our machine on how to mount a remote folder by using SSH protocol.
Step1: Installing Package
On Ubuntu/Debain
apt-get install sshfs
On Redhat/CentOS/Fedora
rpm -ivh fuse-sshfs-1.8-1.el5.rf.i386.rpm
Step2: Once the package is installed we have to create a mount point and mount our server data using sshfs command, for which we require username/password. Here are my details for this task.
My Username: root My password: redhat My Server: 10.233.10.212 My mount point: /mnt/ssh
Now create the mount point and mount SSH account data.
#mkdir /mnt/ssh #sshfs root@10.233.10.212:/ /mnt/ssh/ root@10.233.10.212's password:
Step3: The above command will mount my root directory in 10.233.10.212 server. Testing our setup
Check if you are able to see data
#cd /mnt/ssh
#ls
Sample output
bin cdrom data etc initrd.img lib media opt root selinux sys tmp var vmlinuz.old
boot cmdb-bkp dev home initrd.img.old lost+found mnt proc sbin srv test usr vmlinuz
What about df -hs command output?
Sample output
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 12G 8.4G 2.5G 78% /
/dev/sda6 80G 43G 34G 56% /var
/dev/sda5 2.0G 41M 1.8G 3% /home
/dev/sda1 99M 12M 83M 12% /boot
tmpfs 506M 0 506M 0% /dev/shm
sshfs#root@10.233.10.212:/ 1000G 0 1000G 0% /mnt/ssh
Step4: So what about mounting it permanently?. We can do it by editing fstab file in /etc folder
#vi /etc/fstab
go to last line and type below line
sshfs#root@10.233.10.212:/ /mnt/ssh fuse defaults 0 0
Save the file and exit. Now run mount -a to update the fstab file state to kernel.
Note: Its not advisable to write passwords in human readable files like /etc/fstab.
#mount -a
Let me explain what entry in fstab indicates. We are mentioning mount user root data which is located on 10.233.10.212 server on to /mnt/ssh using fuse file system with default settings.
Step5: What about unmounting this drive?
#umount /mnt/ssh
Enjoy new learning of mounting a folder using SSH protocol.
How to mount a remote directory in Linux using sshfs的更多相关文章
- 【Linux基础】mount报错:mount.nfs: Remote I/O error
问题描述:mount 报错:mount.nfs: Remote I/O error 挂载时需要指明版本,由于NFS服务器有多个版本,V2.V3.V4.而且各版本同时运行,因此挂载时需要说明版本号. 由 ...
- How to Mount a Remote Folder using SSH on Ubuntu
Connecting to a server across the internet is much more secure using SSH. There is a way that you ca ...
- Linux使用sshfs通过ssh挂载远端机器
Linux使用sshfs通过ssh挂载远端机器 今天自己的开发机器突然磁盘剩余空间报警,再弄一块硬盘不太现实,于是想到了公司有一台机器上挂了一个大的磁盘,于是,我把目标偷偷锁定到了那个机器上. 折腾了 ...
- Linux安装sshfs挂载远程目录到本地及卸载
挂载远程目录的方式很多,这里把sshfs记录一下备忘.Linux用sshfs挂载远程目录到本地 安装sshfs 在Ubuntu下,只需要使用 $ sudo apt-get install sshfs ...
- Mount Windows (CIFS) shares on Linux with credentials in a secure way
Posted on 09/09/2014 In almost all cases, when mounting a CIFS-share on a Linux host, you will nee ...
- 使用VS Code配合Remote Development插件连接远程服务器(Mac/Linux+Windows) | Using VS Code with Remote Development Connect to Remote Server (Mac/Linux+Windows)
最新版VS Code(2019年6月)出了一系列新的插件,包括Remote Development,Remote SSH等,使得用户可以使用VS Code远程连接服务器写代码,方便了协同工作.具体配置 ...
- How to restrict root user to access or modify a file and directory in Linux
Now in this article I will show you steps to prevent or restrict access of root user to access certa ...
- 如何利用mount命令将另外一个linux服务器上的目录挂在到本机?
你先要在192.168.1.100上开启NFS服务并编辑/etc/exports文件: chkconfig --level 35 nfs on service nfs start vi /etc/ex ...
- 【442】Remote control GUP Linux
参考:上传文件到GPU服务器并运行文件 参考:WinSCP 参考:Python远程调试图文教程(一)之Pycharm Remote Debug 参考:教程 | 使用 PyCharm 连接服 ...
随机推荐
- VS2015 create a C++ console application based on WinRT
1. Enable /ZW 2. Disable /Gm 3. #using C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcpack ...
- 201671010140. 2016-2017-2 《Java程序设计》java学习第九周
第七章:<异常,断言和日志>知识点小结 本周,进行了对Java中的异常处理的了解学习,以下是部分所得. 一.未检查异常与已检查异常的区别: 未检查异常处理方法:1.捕获2.继续 ...
- JAVA中List的几个方法
add()方法.插入某个位置的数据,他有两个参数一个参数是下标,一个参数是元素.需要注意的是下标大小应该小于等于List集合大小,否则就会抛出下标越界异常! 代码: public static ...
- 第五章 大数据平台与技术 第13讲 NoSQL数据库
NoSQL不是不用SQL,是Not only SQL,不仅仅是结构化的查询. NoSQL兴起的原因 在Web2.0时代新浪一分钟可以发送两万条微博,苹果可以下载4.7万次应用. 数据的高并发性,同时有 ...
- 接口自动化 Windows + HttpRunner 初探(一)
运行环境 HttpRunner 是一个基于 Python 开发的测试框架,可以运行在 macOS.Linux.Windows 系统平台上. HttpRunner 的开发环境为 macOS + Pyth ...
- linux系统中的变量
一.定义 所谓的变量,就是就是利用一个特定的"名称"(name)来存取一段可以变化的"值"(value),简单说来就是“用一个名称储存一个数值”. 二.设定 ...
- kubernetes基础环境配置
一.基础环境配置 环境详情 主机名(FQDN) IP地址(NAT) 描述 linux-node1.example.com eth0:192.168.56.11 1VCPU.2G内存.一块硬盘s da5 ...
- ansible介绍与安装
一.什么是ansible ansible是python中一套模块,系统中的一套自动化工具,可以用来作系统管理.自动化命令等任务. 二.ansible优势 .ansible是Python中一套完整的自动 ...
- loadrunner-27077报错解决办法
警告 -27077: “每次迭代模拟一个新用户”运行时设置为“开”时,“vuser_init”节将包含 Web 函数.这可能会产生具有多次迭代的不可预测结果 [MsgId: MWAR-27077] ...
- Zedboard学习(一):移植Ubuntu桌面操作系统 标签: ubuntu移植zedboardFPGA 2017-07-04 21:53 26人阅读
环境准备: 首先,需要的肯定是Ubuntu操作系统.可以在自己的电脑上安装物理机,也可以是虚拟机下运行的.我的是在Vmware下运行的Ubuntu14.04 32位操作系统. 由于zedboard上的 ...