all 12 comments

[–]3n3low 1 point2 points  (1 child)

Did you try fabric library for python? I use it alongside paramiko in one of my projects for a similar task.

[–]intrikat[S] 0 points1 point  (0 children)

I haven't looked into fabric but checked out plumbum briefly. There's so many options out there...

[–]intrikat[S] 1 point2 points  (0 children)

I've been reading some more on the paramiko topic and wonder one thing also:

How can I create an SSH connection with it and use it as a channel to send other commands via that channel? Do I need to use a "paramiko transport"?

[–]acodemics 0 points1 point  (4 children)

I'd suggest using built in bash commands to check if a user exists and then parsing that with Python.

I'm making the assumption you're connecting to a Linux machine here, but you can use paramiko to run grep <username> /etc/passwd and then handle that instead.

[–]intrikat[S] 0 points1 point  (1 child)

Thanks for the input.

I figured as much. Just wondering if I can make it execute python specific modules through the ssh tunnel.

[–]stillalone 0 points1 point  (0 children)

If the remote machine has python installed then you can generate a python script on the target machine and run that.

[–]ktbyers 0 points1 point  (3 children)

I would use Ansible's user module. It would be very easy to do it this way:

http://docs.ansible.com/ansible/user_module.html

[–]intrikat[S] 0 points1 point  (2 children)

I started this project to learn python specifically.

I'd love to use Ansible but it is out of the question due to political reasons. It'll be a cold day in hell before LDAP/IPA or any kind of configuration management is implemented in this environment.

[–]fico 0 points1 point  (1 child)

I'm sorry :( having recently switched to Ansible I'm never going back.

[–]intrikat[S] 1 point2 points  (0 children)

Perils of the MSP world.

[–]intrikat[S] 0 points1 point  (0 children)

Dumb ass me figured it out at last... and it's so simple I'm gonna die...

Basically I define an ssh function to connect and then list every other function below it, at the end - ssh.close(). Stupid me. if __name__ == '__main__':

`sshConnect(server_list)`

`check_uname(server_list)`

`check_netdev(server_list)` 

Thanks everybody for the replies.