Quantcast
Channel: Execute commands using sudo in remote server after logging into PuTTY through batch file - Super User
Viewing all articles
Browse latest Browse all 2

Execute commands using sudo in remote server after logging into PuTTY through batch file

$
0
0

I need to login into remote server daily and perform same set of tasks. I am using Windows platform and the remote server is Unix. I use PuTTY to login to remote server. To reduce the manual work, I need to automate this task.

I tried this code:

start putty.exe -ssh -load session -l username -pw password -m command.txt -t

The command.txt contains:

sudo su - user1 ls cd directory

Only the first command in command.txt is working and then PuTTY is expecting input from user.

I need all the commands to be run without user input.

Things that matters :

  • I am not root user

  • Access granted to switch to the user1 without password

  • I have a constraint of using PuTTY only (Plink installation is notpermitted)


Viewing all articles
Browse latest Browse all 2

Trending Articles