Python Forum
[Tkinter] Access a remote server with ssh
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Access a remote server with ssh
#1
Hello all,

This is my first post, new python dev, and really interested in learning more.

I am wanting to make a GUI environment for my team to help with a lot of monotonous work.

Essentially, what I want is a program we can open up (for both windows and mac. Figured this would be easier with python and tkinter), have a button that will make the ssh connection, then a few other buttons that call other .py scripts that we already have on the remote server to pull logs and what not.

I have the general layout in mind, I'm just not sure how to implement the ssh option and the other .py scripts when the button is pressed for that certain script.

Any ideas on how to easily implement this?
Reply
#2
The most basic, but powerful snippet about this is this one
import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('111.111.1.1', username='User', password='Password', allow_agent = False)

i, o, e = ssh.exec_command('mycommand')
print(o.readlines())
I haven't been using it for a while, so check Paramiko's documentation.

This is a low level solution. For high level solutions you could look in modules such as fabric
Reply
#3
(Sep-08-2018, 10:09 AM)Gribouillis Wrote: The most basic, but powerful snippet about this is this one
import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('111.111.1.1', username='User', password='Password', allow_agent = False)

i, o, e = ssh.exec_command('mycommand')
print(o.readlines())
I haven't been using it for a while, so check Paramiko's documentation.

This is a low level solution. For high level solutions you could look in modules such as fabric


This is helpful but I'm wondering... can I can automate the installation of paramiko? I want it to be as seamless as possible.
Reply
#4
I think running
Output:
python -m pip install paramiko
should install paramiko.
Reply
#5
(Sep-09-2018, 05:50 AM)Gribouillis Wrote: I think running
Output:
python -m pip install paramiko
should install paramiko.

Hey, to kind off help show what I want to do, here is a quick sketch up.
Image of layout

I have the layout... I just need the functionality. I should mention, that the server that hosts our logs uses BASH shell to grab all of the logs we request, however the commands we use to grab the logs are made with python.
Reply
#6
I was able to get paramiko installed. I'm not sure how to make (perhaps import a terminal app) into python. So far, through pip, I install terminal and simple_terminal. However, I'm not sure how to actually USE those. I just need a terminal window in the gui to see the output when I press the buttons. I can focus on paramiko later. It's installed and imported... just can't understand how to actually get it tp connect to a host.
Reply
#7
What are you trying to do to connect to the server?
Are you substituting your values in this:
ssh.connect('111.111.1.1', username='User', password='Password', allow_agent = False)
If you are can you show your code and the errors you get?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020