How can i change user name for linux machine in batch file.
Moderator: DosItHelp
-
- Posts: 6
- Joined: 04 Oct 2012 04:43
How can i change user name for linux machine in batch file.
Hi,
I have batch file which will start plink.exe to login into remote linux machine:
"start C:\Users\279293\Desktop\PLINK.EXE -ssh -P 22 prateek@10.205.198.34 -pw password"
Now i to change username(prateek) to login as webadmin and also providing password. So what I'm doing, i'm appending "echo password-1 ^| sudo su – webadmin " i.e.,
"start C:\Users\279293\Desktop\PLINK.EXE -ssh -P 22 prateek@10.205.198.34 -pw password echo password ^| sudo su – webadmin"
when i execute the batch file it shows the error : Sorry user prateek is not allowed to execute "/bin/su" webadmin as root on webDevprateekpip. Is my batch command is wrong or what?
Thanks...
I have batch file which will start plink.exe to login into remote linux machine:
"start C:\Users\279293\Desktop\PLINK.EXE -ssh -P 22 prateek@10.205.198.34 -pw password"
Now i to change username(prateek) to login as webadmin and also providing password. So what I'm doing, i'm appending "echo password-1 ^| sudo su – webadmin " i.e.,
"start C:\Users\279293\Desktop\PLINK.EXE -ssh -P 22 prateek@10.205.198.34 -pw password echo password ^| sudo su – webadmin"
when i execute the batch file it shows the error : Sorry user prateek is not allowed to execute "/bin/su" webadmin as root on webDevprateekpip. Is my batch command is wrong or what?
Thanks...
Re: How can i change user name for linux machine in batch fi
I really don't have an answer to your question but I am confused as to why you would use SUDO to run the SU command. The point of the SUDO command is so you don't have to run SU. Been a long time since I was a linux admin so I could just be totally wrong.
Re: How can i change user name for linux machine in batch fi
Interesting point, unless he isn't logged in as Root.
The passwords indicated in the script aren't the same...
I don't have an answer either...
The passwords indicated in the script aren't the same...
I don't have an answer either...
-
- Posts: 6
- Joined: 04 Oct 2012 04:43
Re: How can i change user name for linux machine in batch fi
@ Squashman : I really don't know about sudo command, infact i'm windows guys just wanted to run batch file in windows which will perform the remote login in linux machine for user "prateek" and then wanted to change login name or login as "webadmin" with password "password". So, what batch command will there to do this.
Thanks for your help.
Thanks for your help.
-
- Posts: 6
- Joined: 04 Oct 2012 04:43
Re: How can i change user name for linux machine in batch fi
@foxidrive : Sorry for that, both password are same that is "password".
Re: How can i change user name for linux machine in batch fi
My thought is: why not log in as webadmin to begin with?
You can try an interactive session to see if you can use sudo to perform the login.
http://the.earth.li/~sgtatham/putty/0.5 ... pter7.html
Another point is that piping a phrase through a pipe to an executable isn't always supported by the executable.
You can try an interactive session to see if you can use sudo to perform the login.
http://the.earth.li/~sgtatham/putty/0.5 ... pter7.html
Another point is that piping a phrase through a pipe to an executable isn't always supported by the executable.
-
- Posts: 6
- Joined: 04 Oct 2012 04:43
Re: How can i change user name for linux machine in batch fi
@foxidrive : Actually i need to login in that machine by giving my credentials( u: prateek, p: password), then i can login as webadmin which prompt for password that is same password which is for user prateek i.e, password. This all thing can be done with putty , but i want run plink.exe by batch file to do this.
I tried to login as webAdmin directly, but it ask for password then i give same password again and again it is not accepting, saying Access denied.
However when i do manually with putty then it works well.
I tried to login as webAdmin directly, but it ask for password then i give same password again and again it is not accepting, saying Access denied.
However when i do manually with putty then it works well.
Re: How can i change user name for linux machine in batch fi
If you can't do it with Plink but can do it interactively with Putty then maybe a connection via Plink doesn't have the right permissions, at a guess.
Try it again - be certain you haven't typo'd the password or username.
PrateekThakur wrote:I tried to login as webAdmin directly, but it ask for password then i give same password again and again it is not accepting, saying Access denied.
However when i do manually with putty then it works well.
Try it again - be certain you haven't typo'd the password or username.
-
- Posts: 6
- Joined: 04 Oct 2012 04:43
Re: How can i change user name for linux machine in batch fi
foxidrive wrote:If you can't do it with Plink but can do it interactively with Putty then maybe a connection via Plink doesn't have the right permissions, at a guess.PrateekThakur wrote:I tried to login as webAdmin directly, but it ask for password then i give same password again and again it is not accepting, saying Access denied.
However when i do manually with putty then it works well.
Try it again - be certain you haven't typo'd the password or username.
Yeh, you are right password was not correct. Thanks.. So, right now it is not working by both plink or putty, if i directly login as webadmin , same message : Access denied.
Re: How can i change user name for linux machine in batch fi
I have no answer - and I don't have the means to test it.
-
- Posts: 6
- Joined: 04 Oct 2012 04:43
Re: How can i change user name for linux machine in batch fi
foxidrive wrote:I have no answer - and I don't have the means to test it.
@fordrive : Thanks for your assistance. I got solution for this using Process class in c sharp to automate this process, rather using bath file. And its doing pretty good.
Thanks.
Re: How can i change user name for linux machine in batch fi
I was always taught to not allow ROOT or any other user with Elevated privileges to login directly with SSH. You login with your normal user and then use SUDO to run any commands that require elevated privileges. That is how all my servers were setup when I was a Linux admin.