use sshfs to mount remote filesystem , command sample

安裝 command :
apt-get install sshfs

sshfs [user@]host:[remote_directory] mountpoint [options]

sshfs -p 2200 [email protected]:/home/rimmon DEV

fusermount -u DEV

sshfs -p 2200 -o reconnect [email protected]:/mnt/tslog_bak ~/TSLOG_BAK

fusermount -u ~/TSLOG_BAK

速度測試

sshfs -p 2200 -o reconnect [email protected]:/mnt/tslog_bak ~/TSLOG_BAK

1.1G 費時 19秒 , 約 55MB/s

Use dd command to backup whole disk to image file , acer desktop , win7 , pv(pipe viewer example)

Acer ASPIRE M1930 partition layout

Same PC but install windows7

 

-- OK! 在 virtualbox 測試
dd if=/dev/sda | pv | ssh -p 2200 [email protected] 'cat > winxp2.dd.img'
ssh -p 2200 [email protected] 'cat winxp2.dd.img' | pv | dd of=/dev/sda

-- OK! 把 Acer PC 整個硬碟備份到遠端 server 的 image file
dd if=/dev/sda | pv | ssh -p 2200 [email protected] 'cat > /mnt/m1/acer-pc-win7.dd.img'

-- OK!把 Acer PC 改裝 windows7 後, 備份到遠端 server
-- 用 pv 看進度 , pipe 給 gzip 壓縮後再透過 ssh 傳到遠端 server ,
dd if=/dev/sda | pv | gzip | ssh -p 2200 [email protected] 'cat > /mnt/m1/desktop-win7.dd.img.gz'

976773168+0 records in
976773168+0 records out
500107862016 bytes (500 GB, 466 GiB) copied, 12321.3 s, 40.6 MB/s

94G     desktop-win7.dd.img.gz


[memo] ssh tunnels

2023.1130

ssh -D 12345 -o TCPKeepAlive=yes -o ServerAliveInterval=10 -p 2200 [email protected]
連進 ovh3 後, 並在本機起一個 12345 port,(LISTEN 12345)

修改 mac 的網路設定,使用 socks proxy

———-

在本機的 4080 建立一個 ssh tunnel 經由 bq.monster.tw 連入到內網 home.monster.tw 的 4080 port, 使用 browser 連 127.0.0.1:4080

ssh -L 4080:home.monster.tw:4080 -o TCPKeepAlive=yes -o ServerAliveInterval=10 -p 2200 [email protected]

ssh -D 12345 -o TCPKeepAlive=yes -o ServerAliveInterval=10 -p 2200 [email protected]

ssh -D 12345 -o TCPKeepAlive=yes -o ServerAliveInterval=10 [email protected]

ssh -L 33389:192.168.100.2:3389 -o TCPKeepAlive=yes -o ServerAliveInterval=10 -p 2200 [email protected]

 

# —–
ssh -L 8000:192.168.1.1:80 -o TCPKeepAlive=yes -o ServerAliveInterval=10 -p 2200 [email protected]
說明: 在本機端(port 8000) 建立一個與 desktop.monster.tw 的 ssh (port 2200) 通道, 由 desktop.monster.tw 連向 192.168.1.1 的 port 80
所以只要用 browser 連到本機 http://127.0.0.1:8000 即可連入 192.168.1.1:80

URL: OSX ssh tunnel

 

 

用 browser 連到本機 http://127.0.0.1:33890 即可連入 192.168.100.101:3389
ssh -L 33890:192.168.100.101:3389 -o TCPKeepAlive=yes -o ServerAliveInterval=10 -p 2200 [email protected]

 

 

Use Subversion with SSH on non standard port / svn on ssh tunnels

server 端:

rimmon@chicago:~$ pwd

/home/rimmon

rimmon@chicago:~$ svnadmin create SVN

改 SVN/conf/svnserve.conf

[general]
anon-access = none
password-db = passwd
realm = Chicago_SVN

client 端:

在 ~/.subversion/config

加上

### Section for configuring tunnel agents.
[tunnels]
mmm = ssh -p 2200 -q


checkout :

svn co svn+mmm://chicago.monster.tw/home/rimmon/SVN .

 

Screenshot 2016 08 27 21 16 32

 

cat .subversion/config

 

[tunnels]
foo = ssh -p 2200
### Configure svn protocol tunnel schemes here. By default, only
### the ‘ssh’ scheme is defined. You can define other schemes to
### be used with ‘svn+scheme://hostname/path’ URLs. A scheme
### definition is simply a command, optionally prefixed by an
### environment variable name which can override the command if it
### is defined. The command (or environment variable) may contain
### arguments, using standard shell quoting for arguments with
### spaces. The command will be invoked as:
### <command> <hostname> svnserve -t
### (If the URL includes a username, then the hostname will be
### passed to the tunnel agent as <user>@<hostname>.) If the
### built-in ssh scheme were not predefined, it could be defined
### as:
# ssh = $SVN_SSH ssh -q
### If you wanted to define a new ‘rsh’ scheme, to be used with
### ‘svn+rsh:’ URLs, you could do so as follows:
# rsh = rsh
### Or, if you wanted to specify a full path and arguments:
# rsh = /path/to/rsh -l myusername
### On Windows, if you are specifying a full path to a command,
### use a forward slash (/) or a paired backslash (\\) as the
### path separator. A single backslash will be treated as an
### escape for the following character.

 

svn co svn+foo://nyc.monster.tw/home/SVN/repos .