Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
How to run a shell script over ssh with resource(.txt files) in one machine and the script in another machine?

I want to run a shell script using SSH which takes resource from other machine while the script is in some other machine, all on the same network. I don't want to copy the resource to the local machine.

Note: The shell script takes .txt file as input

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Try this:

 ssh USER_NAME@HOST_ADDRESS "BASH_SCRIPT_FILE_PATH"

You will need to provide password whenever required.

over 4 years ago · Santiago Trujillo Report

0

If you have script.sh on server1 and file.txt on server2, you can connect through ssh to server1, and then do:

[user@server1]$ ssh user@server2 "cd mydir && cat file.txt" | ./script.sh
over 4 years ago · Santiago Trujillo Report

0

If your script is in Machine A, you can't run that on Machine B without copying it over. First, copy the script over to Machine B using scp

[user@machineA]$ scp /path/to/script user@machineB:/home/user/path

Then, just run the script

[user@machineA]$ ssh user@machineB "/home/user/path/script"

This will work if you have given executable permission to the script.

OR

Try this one..

<hostA_shell_prompt>$ ssh user@hostB "ls -la"

That will prompt you for password, unless you have copied your hostA user's public key to the authorized_keys file on the home of user .ssh's directory. That will allow for passwordless authentication (if accepted as an auth method on the ssh server's configuration)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!