1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# # [service server (samba)] --R--> [relay server] <--L-- [mount server] # service_port=445 service_private_key=/home/user/.ssh/id_rsa relay_server_address=example.com relay_server_ssh_port=22 relay_server_username=USERNAME relay_server_port=60445 mount_port=50445 mount_path=share mount_username=smbuser mount_password=smbpasswd mount_point=/home/user/mount_1/ mount_private_key=/home/user/.ssh/id_rsa # service server (samba) /usr/bin/autossh $${relay_server_username}@${relay_server_address} -p ${relay_server_ssh_port} -R ${relay_server_port}:localhost:${service_port} -i ${service_private_key} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -CN # mount server /usr/bin/autossh ${relay_server_username}@${relay_server_address} -p ${relay_server_ssh_port} -L ${mount_port}:localhost:${relay_server_port} -i ${mount_private_key} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -CN /usr/bin/sudo /bin/mount -t cifs server=//localhost/${mount_path} -o port=${mount_port},username=${mount_username},password=${mount_password},rw,file_mode=0777,dir_mode=0777 |