Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to login in remote server via putty. I'm writing batch file for this :

@echo off start C:\Users\Prateek\Desktop\PUTTY.EXE -ssh -P 22 user@host -pw password

Then i need to login as sudo su user(say userAdmin) with password, which i need to write in batch file. I don't know how to change the user in batch command line. I mean what will be command in batch file.

Thanks in advance.

share|improve this question

1 Answer 1

Have a look at Plink! It's made by the people who made Putty and its purpose is for exactly what you try to use putty for in your question.

Plink (PuTTY Link) is a command-line connection tool similar to UNIX ssh. It is mostly used for automated operations.

From the Plink Manual:

7.3 Using Plink in batch files and scripts

Once you have set up Plink to be able to log in to a remote server without any interactive prompting (see section 7.2.2), you can use it for lots of scripting and batch purposes. For example, to start a backup on a remote machine, you might use a command like:

plink root@myserver /etc/backups/do-backup.sh

Or perhaps you want to fetch all system log lines relating to a particular web area:

plink mysession grep /~fred/ /var/log/httpd/access.log > fredlog

Any non-interactive command you could usefully run on the server command line, you can run in a batch file using Plink in this way.

Plink Download Link

share|improve this answer
    
Thanks much Riscie.. –  Prateek Sep 18 '12 at 7:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.