Solved

Linux, ssh script for remote execution

Posted on 2013-12-18
2
409 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 29

Accepted Solution

by:
serialband earned 250 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 250 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

728 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