?
Solved

Linux, ssh script for remote execution

Posted on 2013-12-18
2
Medium Priority
?
410 Views
Last Modified: 2013-12-19
From a previous thread I found I could do the following to run a command remotely

putty -t user@host -pw password -m local_commands_file

Open in new window


How can I do this with ssh instead of putty >

Thanks
0
Comment
Question by:Los Angeles1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
serialband earned 1000 total points
ID: 39727973
You shouldn't enter a password on a command line or store it in a file.  You should use ssh keys and preload your passphrase with ssh agent, if you don't want it to prompt you for a password..

Load your key
eval ssh-agent
ssh-add YOUR_SSH_KEY

Then you can ssh to systems that have your key in the authorized_keys file without using a password.
ssh user@host  "COMMAND1; COMMAND2; COMMAND3; ETC..."

In putty, you would run pageant.exe and load your key and you'd run your command without the -pw option.
0
 
LVL 19

Assisted Solution

by:xterm
xterm earned 1000 total points
ID: 39728107
You can install the cygwin environment and openssh which will give you the ssh command in windows.

Then you can just run from a cmd window:

ssh user@host /path/to/your_commands.sh

(it will prompt you only the first time to save the server's key, but every time for your password)
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question