-1

I want to write a program that gets a list of servers(VPS) and checks if the server is available and the username and password are right. So I googled it and there was nothing about connecting to a VPS through python. Is it possible?? If it is How? Thank you

Miad Abdi
  • 831
  • 10
  • 17

1 Answers1

0

I’m assuming you want to SSH into the VPS. To do that in Python you’ll have to find a module that allows you to establish SSH connections. I recommend Paramiko to do that. Here is a quick example on how you would go about connecting to a server:

import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('ssh.example.com')
stdin, stdout, stderr = client.exec_command('ls -l')

Or if you want to use username and password instead:

import paramiko
client = paramiko.SSHClient()
client.connect('ssh.example.com', username='root', password='toor')
stdin, stdout, stderr = client.exec_command('ls -l')
SitiSchu
  • 1,361
  • 11
  • 20
Aron B.
  • 266
  • 1
  • 6
  • Well, I have a few Windows VPS and the port is 3389 which is for RDP. Is it possible to connect to them by ssh? – Miad Abdi Nov 30 '19 at 19:09
  • Well, I have a few Windows VPS and the port is 3389 which is for RDP. Is it possible to connect to them by ssh? if not ,Is there a way to connect to a windows VPS? – Miad Abdi Nov 30 '19 at 19:22
  • You could try to use https://github.com/citronneur/rdpy, but I recommend you just set up an SSH server on Windows: https://www.bleepingcomputer.com/news/microsoft/how-to-install-the-built-in-windows-10-openssh-server/ – Aron B. Dec 02 '19 at 08:10