SSH to overseas server too slow?

UPDATE (2018-05-03):

I ended up using a BandWagon VPS as high volume traffic proxy with an AEAD encryption method and another faster one as a backup instead of those ssh forwarding stuff, it was unstable and quickly fallen only one month later and never be fast again.


The original post:

Use China mainland cloud server as a hop.

1
ssh -v -N -L 2222:remote.oversea:2222  cloud.mainland

Then:

1
ssh -p 2222 root@localhost

Or even mount as a local folder:

1
sshfs -p 2222 root@localhost:/var/www/html ~/docker/nhweb -oauto_cache,reconnect,defer_permissions,noappledouble,negative_vncache,volname=nhweb

A few sweet ssh features to improve your development experience.

Expose local port to internet with a delegate:

1
2
3
4
5
6
7
# Remote server
sudo vi /etc/ssh/sshd_config
# Append below content:
# GatewayPorts yes

# Local
ssh -v -N -R *:9090:localhost:8080 cloud.mainland

Then heading to http://cloud.mainland:9090 for the results.

Ref:

Ultimate docker on OSX collection - mapping docker files to local

Yes, you’ve heard, and have looked around here, here, or maybe here, it’s different to Linux with a simple volume mapped to your local machine. In OSX world, Docker is working in a VirtualBox…

So the file permission got be a problem, you can’t simply change its group or permission, neither. let’s fix it.

The idea is like this:

  • Everything in Docker operate as normal.
  • Create a new docker container that serves a ssh endpoint.
  • Connect to that ssh point, and get access to the file system inside our docker.
  • Get deeper, map the files of docker volume to local file system.

Let’s get started.

Run your containers as normal.

Go to your docker-compose directory, edit the file docker-compose.yml.

1
2
3
4
5
6
7
8
9
sshd:
image: 'krlmlr/debian-ssh'
ports:
- '2222:22'
environment:
- SSH_KEY=ssh-rsa AAAAxxxx_ssh_rsa_pub_content rankun203@gmail.com
volumes_from:
- data
working_dir: /var/www/html

Run it

1
docker-compose up sshd

Mount the docker file system to your local file system:

1
sshfs -p 2222 root@youdar.dev:/var/www/html ~/docker/nhweb -oauto_cache,reconnect,defer_permissions,noappledouble,negative_vncache,volname=nhweb

Notes:

  • volname=nhweb is the directory name of the mount point.
  • ~/docker/nhweb is the mount point.
  • These options are selected for more friendly and less errors.

Now your local folder ~/docker/nhweb are just the same as inside the Docker, but with the right access rights.

Notes:

  • All the file created by you will on the name of root user inside the docker.
  • If you want to use another limited user with sudo permission, use docker.

References: