Solved

Linux, ssh script for remote execution

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't See Site After DNS Resolved 7 55
nagios alerts 3 46
CentOS create a user with predefined MD5 Hashed password 17 85
AD LDAP LDS 3 66
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…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

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