0
点赞
收藏
分享

微信扫一扫

远程挂载sftp

1.A机器上启用sftp,编辑 /etc/ssh/sshd_config

Subsystem        sftp        internal-sftp
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
Match Group sftp
        ChrootDirectory /data1/sftpfile
        ForceCommand internal-sftp
        AllowTcpForwarding no
        X11Forwarding no

将用户sftpuser加入到sftp组中,赋予用户sftpuser和组sftp /data1/sftpfile目录权限

2.B机器上使用sshfs挂载A机器上的sftp

sshfs -p 22 sftpuser@10.10.2.6:/ /testly  #将10.10.2.6上的sftp根目录挂载到 /testly上

卸载:umount /testly

3.开机自动挂载:

vim /data/scripts/mountsftp.sh,赋予可执行权限

echo sftppassword | /usr/bin/sshfs -p 22sftpuser@10.10.2.6:/ /testly -o reconnect -o cache=yes -o allow_other -o nonempty -o password_stdin

 编辑 /etc/rc.local:

/data/scripts/mountsftp.sh

 

通过chkconfig设置开机自启动:

https://cloud.tencent.com/developer/article/2146162

举报

相关推荐

0 条评论