Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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/

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


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.