Solved

Linux, ssh script for remote execution

Posted on 2013-12-18
2
404 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
2 Comments
 
LVL 27

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now