-1

I am already connected to a remote server using ssh with running the following command

ssh user@ip

and connected to that server and I am in that server terminal now.

I want to execute a script exist on my loca machine on the remote server while I am connecting to it.

I know that there is another way to do that by doing something like this

ssh serverA "bash -s" -- < ./ex.bash

but my case is different, I want to execute the script after connecting to the server

how can I do that?

tarek salem
  • 540
  • 1
  • 6
  • 20
  • Perhaps the most convenient way to copy files between two hosts is to use `rsync`. In your case, use this to copy `ex. bash` to the remote server. – user1934428 Apr 19 '23 at 09:34

1 Answers1

0

Without a shared volume, like via NFS, you can't do it. If it's a simple script then you can scp /some/ex.bash remote:/tmp/ex.bash and then when you ssh to remote you can run /tmp/ex.bash.

Setting up NFS is more involved than an SO answer. See something like: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-20-04

keithpjolley
  • 2,089
  • 1
  • 17
  • 20