0

Here's my current predicament: I need to change the password to a user account on 2000 devices running Ubuntu 16.04. I want to do this remotely via Plink rather than SSH. On all these appliances, the username is TESTUSER and password is TESTPASS. In short, they all have the same username and password.

Plink script executed via CMD: FOR /F "tokens=1,2* delims=," %G IN (C:\Users\username\Desktop\TEST\Device_IPs.txt) DO echo y | plink -v -ssh -m "C:\Users\username\Desktop\TEST\commands.txt" TESTUSER@%G -pw TESTPASS >> Results.txt 2>&1

In my commands.txt file is echo TESTUSER:TESTPASSNEW | chpasswd

The above command works via SSH flawlessly but only with elevated sudo privileges. In other words:

  1. SSH to device
  2. sudo -i
  3. Input TESTPASS as password
  4. Run echo TESTUSER:TESTPASSNEW | chpasswd

TESTPASSNEW is what I'd like to change the password to. Any suggestions are appreciated!

DJPaul
  • 1
  • 1
  • Why do you ssh as one user and then switch to the other user? – Michael Hampton Mar 26 '19 at 19:53
  • Small correction: I simply do a sudo -i then I run the command not with TESTUSER@Hostname but with root@Hostname. But I cannot SSH to the device using root/password method. I have a less than novice understanding of Linux but hoping people smarter than I am understand what's going on – DJPaul Mar 26 '19 at 20:02
  • Why not put the commands in a .sh file, then download and run the file with plink? – Buffalo Feb 28 '20 at 15:18

0 Answers0