문제

I am executing a python script on one server and needing to read the contents of the passwd file from a remote machine. Does anyone know of a way to do this? Normally I would do:

import pwd
pwlist = pwd.getpwall()
#perform operations

This only works for the current system of course, and I'm needing a way to access another machine (like you would via ssh). Any help is appreciated.

도움이 되었습니까?

해결책

The pwd module will only work for the current machine. It uses the C library functions defined in <pwd.h>, which do not provide any parameters for a remote machine. However, this does not prevent you from using ssh tools to run a script on the remote machine.

다른 팁

You can use a utility such as scp to copy the passwd file locally. Its easy to split the lines and get the information.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top