In the second approach, use
ff.communicate("open vnc://www.example.com\n")
I'd try :
Popen("plink user@host -i key.ppk", shell = True)
Popen("open vnc://www.example.com", shell = True)
Download and install python 2.7 for Windows,Download and install the latest python 3 for Windows,Download plink, the ssh alternative for Windows,Api calls for automatic client creation and download
Your client should now show as active in web interface. You should now start the tunnel which will get you the following prompt:
The server 's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server 's ssh-ed25519 key fingerprint is: ssh-ed25519 256 5c:a0:04:94:74:74:ab:91:90:59:2c:26:64:e8:73:ec If you trust this host, enter "y" to add the key to PuTTY 's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache ? (y / n)
Thanks for contributing an answer to Super User!
Client:
import socket ip = "192.168.xxx.yyy" # replace your ip address # connect to server client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect((ip, 8080)) print("CLIENT: connected") # send a message msg = "I am CLIENT" client.send(msg.encode()) # recive a message and print it from_server = client.recv(4096).decode() print("Recieved: " + from_server) # exit client.close()
Server:
import socket ip = "192.168.xxx.yyy" # replace your ip address # start server serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serv.bind((ip, 8080)) serv.listen(5) print("SERVER: started") while True: # establish connection conn, addr = serv.accept() from_client = '' print("SERVER: connection to Client established") while True: # receive data and print data = conn.recv(4096).decode() if not data: break from_client += data print("Recieved: " + from_client) # send message back to client msg = "I am SERVER" conn.send(msg.encode()) # close connection and exit conn.close() break
Plink (PuTTY Link) is a command-line connection tool similar to UNIX ssh. It is mostly used for automated operations, such as making CVS access a repository on a remote server. , Plink accepts all the general command line options supported by the PuTTY tools. See section 3.7.3 for a description of these options. , Plink also supports some of its own options. The following sections describe Plink's specific command-line options. , Plink can also be used with WinCVS. Firstly, arrange for Plink to be able to connect to a remote host non-interactively, as described in section 7.2.2.
In order to use Plink, the file plink.exe
will need either to be on your PATH
or in your current directory. To add the directory containing Plink to your PATH
environment variable, type into the console window:
set PATH = C: \path\ to\ putty\ directory; % PATH %
Once you've got a console window to type into, you can just type plink
on its own to bring up a usage message. This tells you the version of Plink you're using, and gives you a brief summary of how to use Plink:
Z: \sysosd > plink
PuTTY Link: command - line connection utility
Release 0.56
Usage: plink[options][user @] host[command]
("host"
can also be a PuTTY saved session name)
Options:
-V print version information -
v show verbose messages -
load sessname Load settings from saved session -
ssh - telnet - rlogin - raw
force use of a particular protocol -
P port connect to specified port -
l user connect with specified username -
m file read remote command(s) from file -
batch disable all interactive prompts
The following options only apply to SSH connections:
-pw passw login with specified password -
D[listen - IP: ] listen - port
Dynamic SOCKS - based port forwarding -
L[listen - IP: ] listen - port: host: port
Forward local port to remote address
-
R[listen - IP: ] listen - port: host: port
Forward remote port to local address
-
X - x enable / disable X11 forwarding -
A - a enable / disable agent forwarding -
t - T enable / disable pty allocation -
1 - 2 force use of particular protocol version -
C enable compression -
i key private key file
for authentication
-
s remote command is an SSH subsystem(SSH - 2 only) -
N don 't start a shell/command (SSH-2 only)
To make a simple interactive connection to a remote server, just type plink
and then the host name:
Z: \sysosd > plink login.example.com Debian GNU / Linux 2.2 flunky.example.com flunky login:
If you have already set up a PuTTY saved session, then instead of supplying a host name, you can give the saved session name. This allows you to use public-key authentication, specify a user name, and use most of the other features of PuTTY:
Z: \sysosd > plink my - ssh - session
Sent username "fred"
Authenticating with public key "fred@winbox"
Last login: Thu Dec 6 19: 25: 33 2001 from: 0.0
fred @flunky: ~$
Once you have done all this, you should be able to run a remote command on the SSH server machine and have it execute automatically with no prompting:
Z: \sysosd > plink login.example.com - l fred echo hello, world hello, world Z: \sysosd >
Last updated at 2022-05-26 14:02:42.597682
$ ssh foobar @hostname - or - ip -
o "StrictHostKeyChecking no"
$ plink.exe - ssh foobar @hostname - or - ip - pw "password" - C "uname -a"
$ plink.exe ", " - ssh ", "
foobar @username - or - ip ", " - pw ", "
no secret ", " - C ", "
uname - a "
import subprocess
import sys
ssh = subprocess.Popen([r "c:\Users\foobar\download\plink.exe", "-ssh",
"foobar@username-or-ip",
"-pw", "password",
"-C", "uname -a"
],
shell = False,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
result = ssh.stdout.readlines()
error = ssh.stderr.readlines()
if error:
for err in error:
sys.stderr.write("ERROR: {}\n".format(err))
if result:
print(result)
import subprocess
import sys
ssh = subprocess.Popen([r "c:\Users\foobar\download\plink.exe", "-ssh",
"foobar@username-or-ip",
"-pw", "password",
"-C", "uname -a"
],
shell = False,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
result = ssh.stdout.readlines()
error = ssh.stderr.readlines()
if error:
for err in error:
sys.stderr.write("ERROR: {}\n".format(err))
if result:
print(result)
import subprocess
import sys
ssh = subprocess.Popen([r "c:\Users\foobar\download\plink.exe", "-ssh",
"foobar@username-or-ip",
"-pw", "password",
"-C", "uname -a"
],
shell = False,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
result = ssh.stdout.readlines()
error = ssh.stderr.readlines()
if error:
for err in error:
sys.stderr.write("ERROR: {}\n".format(err))
if result:
print(result)