您的位置:首页 > 运维架构 > Linux

sshfs命令挂载远程目录(debian centos)

2015-06-14 17:47 639 查看
我的博客已迁移到xdoujiang.com请去那边和我交流
项目有台online机器需要迁移到另外1台上去 上面有多个不同目录需要
scp到另外1台上去 发现使用sshfs一次性的将目录挂载过来 在本地复制后在umount
这样省事也方便,也省去每次scp需要敲密码了。

基础环境
severA=192.168.1.122(6.0.10)debian
severB=192.168.1.120(6.6)centos

1、安装sshfs(SSHFS - filesystem client based on ssh)
apt-get -y install sshfs

2、挂载格式
sshfs [user@]host:[dir] mountpoint [options]

3、将severB机器上的/opt/111目录挂载到severA的/mnt下
echo "redhat"|sshfs -o nonempty,allow_other,password_stdin jimmy@192.168.1.120:/opt/111 /mnt

4、参数说明
-o password_stdin read password from stdin (only for pam_mount!)
-o nonempty allow mounts over non-empty file/dir
-o allow_other allow access to other users

5、查看挂载
df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda1     ext3     19G  2.1G   16G  12% /
tmpfs        tmpfs    494M     0  494M   0% /lib/init/rw
udev         tmpfs    490M  156K  490M   1% /dev
tmpfs        tmpfs    494M     0  494M   0% /dev/shm
/dev/sda5     ext3     31G  179M   30G   1% /opt
jimmy@192.168.1.120:/opt/111
fuse.sshfs     26G  244M   25G   1% /mnt
==========================centos===========================
centos直接yum安装(前提是有epel源)
1、查询
yum list |grep sshfs
fuse-sshfs.x86_64                          2.4-1.el6                     epel

2、安装
yum -y install fuse-sshfs
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sshfs mount