0

Is it possible to create a single SSH tunnel to address a remote host like it was sitting on the local system, eg. type the following pseudo-examples locally and achieve the desired effect:

  • Copy databases: mysqldump remote | mysql local or mysqldump local | mysql remote
  • Append text to remote files: echo blah >> remote:file.txt
  • Change remote files: sed ... remote:file.txt
  • Execute remote commands: apk add blah

If a single connection is not possible, what is the most convenient way to achieve these things?

forthrin
  • 2,289
  • Why not use an automation tool like Ansible to do this? – ryekayo Sep 22 '16 at 16:46
  • It's always good to know what standard Unix can do. 2. Can you run spontaneous manual commands on a live system with Ansible & Co.? (I thought they were only for pre-configuration.)
  • – forthrin Sep 22 '16 at 17:09
  • You can run commands using the shell/command modules. However, Ansible is an automation tool that is Python under the hood, so i believe you need to have Python 2.7+. And yes i agree it is good to learn the conventional commands that Linux/Unix has to get a broader understanding of it. – ryekayo Sep 22 '16 at 17:22
  • If this is a duplicate, then (parts of) the proposed answer should be moved over to the duplicate. It's very concise and explains how to do some specific things one would want to do. That said, I feel that this question starts more with "How do I accomplish these tasks?" while the proposed duplicate says specifically "How do I reuse a SSH tunnel"? – forthrin Sep 23 '16 at 06:03