Copy file with su another_userid

Advertisement

BijuGC
Joined:
Posts:
4

Copy file with su another_userid

First of all thanks for WinSCP. As I am more familiar with WinSCP, I use it religiously even though my company provide another proprietary SCP client application.

In my work place, we can access our RedHat Linux system with our userid (authentication controlled by Microsoft Active Directory) or by a generic application user id.
We run all the web apps using app user id, and the application files and directories are under the ownership of app user id.
To copy files from windows to Linux app dirs we login with app user id in WinSCP.

But after the Target department store security breach they are restricting many facilities.
They are removing remote login access for app user id.
We have to login using MS-AD userid, then do su app user id.
This works for PuTTY, but not for WinSCP ( https://winscp.net/eng/docs/faq_su )
As well as my uid is not in the sudoers.

Along with this is another problem, we are unable to do chown or chgrp for files with my id or app user id.
But I can do chmod with my MS-AD user id or app user id for files with respective ownership.

So I do following steps to transfer files from Windows to Linux.

1. In WinSCP Login using ms-ad-uid
2. Run PuTTY, login with ms-ad-uid
3. In PuTTY, su app-uid
4. In PuTTY, go to the destination file transfer directory
5. In PuTTY, run “mkdir x” or another dir name which dont exist
6. In PuTTY, chmod 777 x
7. In PuTTY, cd x
8. In PuTTY, pwd
9. In PuTTY, copy output of pwd
10. In WinSCP, paste the new dir path from the clipboard
11. In WinSCP, copy file from Windows to Linux, wait till file transfer is over
12. In PuTTY, copy the newly transferred file to the parent dir
13. Repeat this process for every file.
14. In PuTTY, goto parent dir of “x”, then “rm -r x”

Now my RFE, is it possible to add an automated process for above steps using windows api SendMessage or some thing.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,405
Location:
Prague, Czechia

Re: Copy file with su another_userid

Did you try to automate this with plink and WinSCP scripting? I assume you need to enter a password for the su command, right?

Reply with quote

BijuGC
Joined:
Posts:
4

Re: Copy file with su another_userid

martin wrote:

I assume you need to enter a password for the su command, right?
correct.

martin wrote:

Did you try to automate this with plink and WinSCP scripting? I assume you need to enter a password for the su command, right?
no.
I don't think you can login as one user and switch to other user with out prompting password. And the su command don't have password as a parameter.
So when I do
plink -ssh my_user_id@app-server su app_user_id
it gives error msg "standard in must be a tty"

Reply with quote

Advertisement

You can post new topics in this forum