Solved

Linux, ssh script for remote execution

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bash script - Exit out of choice loop 2 44
Web resource - Man pages for SUSE Enterprise Linux 11 1 41
Intel fortran compiler (ifort) 5 38
Redhat upgrade 1 26
Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

828 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