🪢
Windows OpenSSH + Linux sshfs
在
1. Windows 10 架設SFTP(SSH Server)
[Link]
v2vsptBUwTEdHsUVyJOw7Tei1A
Windows OpenSSH + Linux sshfs 1
Windows OpenSSH + Linux sshfs 2
Windows OpenSSH + Linux sshfs 3
Windows OpenSSH + Linux sshfs 4
啟動
# SSH
Start-Service sshd
設定⾃動啟動
#
Set-Service -Name sshd -StartupType 'Automatic'
看
# firewall設定
Get-NetFirewallRule -Name *ssh*
Name : OpenSSH-Server-In-TCP
DisplayName : OpenSSH SSH Server (sshd)
Description : Inbound rule for OpenSSH SSH Server (sshd)
DisplayGroup : OpenSSH Server
Group : OpenSSH Server
Enabled : True
Profile : Any
Platform : {}
Direction : Inbound
Action : Allow
EdgeTraversalPolicy : Block
LooseSourceMapping : False
LocalOnlyMapping : False
Owner :
PrimaryStatus : OK
Status : 已從存放區成功剖析規則。 (65536)
EnforcementStatus : NotApplicable
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
RemoteDynamicKeywordAddresses :
如果沒有開
# 22 port ,⽤下⾯指令開啟
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort
Windows OpenSSH + Linux sshfs 5
2.測試連線 。Centos 連到 Windows
yum install epel-release
yum install fuse-sshfs
vi /etc/[Link]打凱 user_allow_other
user_allow_other
su - stevenlin
[stevenlin@centos7 ~]$ mkdir /home/stevenlin/win_user_soft
[stevenlin@centos7 ~]$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet [Link] netmask [Link] broadcast [Link]
inet6 2001:b400:e20f:197:28d1:856e:818a:4040 prefixlen 64 scopeid 0x0<global>
inet6 fe80::6c28:eadd:bbc4:e650 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:3c:d8:d8 txqueuelen 1000 (Ethernet)
RX packets 8191 bytes 9454520 (9.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5202 bytes 475912 (464.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# 透過SSHFS 把 windows 的⽬錄掛進 Centos 7
[stevenlin@centos7 ~]$ echo mkworld1632| sshfs -o reconnect,ServerAliveInterval=1,ServerAliveCountMax=5,StrictHostKeyChecking=no -o password
user@[Link]'s password:
[stevenlin@centos7 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.7M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 2.0G 49G 4% /
/dev/sda1 1014M 138M 877M 14% /boot
/dev/mapper/centos-home 46G 33M 46G 1% /home
tmpfs 396M 0 396M 0% /run/user/0
user@[Link]:D:\software 316G 78G 238G 25% /home/stevenlin/win_user_soft
[stevenlin@centos7 ~]$ ll /home/stevenlin/win_user_soft/
total 8795504
-rw----rwx. 1 root root 4712300544 Mar 23 01:38 CentOS-7-x86_64-[Link]
drwx---rwx. 1 root root 0 Mar 22 20:37 oracle_soft
-rwx---rwx. 1 root root 1225235 Jun 6 2019 setup-x86_64.exe
-rw----rwx. 1 root root 4293066752 Mar 12 2020 [Link]
# 解除連線
fusermount -u -z /home/stevenlin/win_user_soft
核對windows內的檔案
3.測試連線 。Centos 連到Centos
Windows OpenSSH + Linux sshfs 6
mkdir /home/stevenlin/linux_eric_doc
echo mkworld1632| sshfs -o reconnect,ServerAliveInterval=1,ServerAliveCountMax=5,StrictHostKeyChecking=no -o password_stdin -o allow_other e
[stevenlin@centos7 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.8M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 2.0G 49G 4% /
/dev/sda1 1014M 138M 877M 14% /boot
/dev/mapper/centos-home 46G 33M 46G 1% /home
tmpfs 396M 0 396M 0% /run/user/0
user@[Link]:D:\software 316G 78G 238G 25% /home/stevenlin/win_user_soft
eric@[Link]:/home/eric/doc 47G 33M 47G 1% /home/stevenlin/linux_eric_doc
4.測試遠端Server 跨OS。複製檔案。
[stevenlin@centos7 ~]$ cp ~/win_user_soft/setup-x86_64.exe ~/linux_eric_doc/
[stevenlin@centos7 ~]$ ls linux_eric_doc/
setup-x86_64.exe
[stevenlin@centos7 ~]$
[stevenlin@centos7 ~]$ cp ~/win_user_soft/setup-x86_64.exe ~/linux_eric_doc/
[stevenlin@centos7 ~]$ ls linux_eric_doc/
setup-x86_64.exe
[stevenlin@centos7 你好 我來⾃
~]$ echo ' , Linux' > ~/linux_eric_doc/linux_file.txt
[stevenlin@centos7 ~]$ cp ~/linux_eric_doc/linux_file.txt ~/win_user_soft/
[stevenlin@centos7 ~]$ ll ~/win_user_soft
total 8795512
-rw----rwx. 1 root root 0 Sep 6 23:44 aa
-rw----rwx. 1 root root 0 Sep 6 23:44 bb
-rw----rwx. 1 root root 4712300544 Mar 23 01:38 CentOS-7-x86_64-[Link]
-rw----rwx. 1 root root 22 Sep 7 2022 linux_file.txt
drwx---rwx. 1 root root 4096 Mar 22 20:37 oracle_soft
-rwx---rwx. 1 root root 1225235 Jun 6 2019 setup-x86_64.exe
-rw----rwx. 1 root root 4293066752 Mar 12 2020 [Link]
Windows OpenSSH + Linux sshfs 7
Windows OpenSSH + Linux sshfs 8