I am looking for a way to open command prompt of remote PC by using Python. In this process I came only upto open a command prompt from Python and other code is connecting to a windows remote PC but how to combine these two and opening the command prompt of remote PC ?
Simply, I want to send some arguments/commands to remote PC command prompt.
Thank you.
First you need to install SSH on the remote PC's. You test the connection and make sure you are able to login. Google can help if you've not setup ssh before.
Then you can create a python script locally to execute commands over the ssh connection.
You'll probably want to look at either
Fabric -> http://docs.fabfile.org/en/1.8/
or
Paramiko -> http://www.paramiko.org/
Which will be able to run your commands.
Related
I need to create a terminal/console program on my server compute and I want to connect to it with ssh from client. And I want to do it from a python script. So, I figured that I need to somehow have this script run the program (subprocess maybe?) and put it out on the socket.
How can I put out a certain program on a specified socket for ssh connection?
Can I even ssh to a certain program run in a console, not to a whole PC? I need client to have only acces to what I set up.
How can I put out a certain program on a specified socket for ssh connection?
I think that what you actually want to do is changing what is run when logging in with ssh.
You can do this in /etc/passwd by changing /bin/bash to the program you want to run when you log in. Do this for the user that you want to log in to via ssh.
I didn't understand if you wanted to log in from a python script or log in to a python program in an interactive shell, so:
You can use the paramiko library to log into a machine with ssh. (if that is what you want)
I need to create a terminal/console program on my server compute and I want to connect to it with ssh from client.
You can look at this project https://github.com/python-cmd2/cmd2 to build interactive console programs in python.
Here is what I am trying to do. I have a Windows VM and another Linux VM which is used as server. I have Spyder installed on my Windows VM and would like to run my Python code in Spyder on remote Linux server.
I did try using option in Spyder called "Connect to remote kernel" but it did not work and I am getting error "Could not open ssh tunnel ; Paramiko not available". I was using username#servername:22 for making ssh connection. Needless to say, I am able to ssh the machine using putty but not using Spyder. Any ideas how should I fix this?
I found another way to make a connection to an external server, here is the link explaining step by step.
Basically, you have to connect your client PC to the server through a PuTTY SSH tunnel, it will allow to redirect the client ports to the correct ipython kernel server ports.
I have made a connection between my openssh client and server. Both sides are window machine. I fail to do the followings:
Enter the python command line interface on my SSH client side, which can be done by entering "python" directly through a command line.
I want to run a python script on a server side by calling it on my client side. This script calls a commercial library to download data from a commercial database.
I can do both perfectly through remote desktop on the server side, but when I use openssh to connect, all fail. Any way to solve, especially item (2)?
If Python is installed on the remote server as C:\Python27 and the script is C:\Foo\bar.py, then get PuTTY. It contains the program plink.exe which can execute remote commands.
The command for you should be
plink.exe user#remote C:\Python27\python C:\Foo\bar.py
as explained in http://the.earth.li/~sgtatham/putty/0.64/htmldoc/Chapter7.html#plink-usage
I was wondering if it is possible to execute the following :
My Script in UNIX server \HOME\Script folder(File Name:MyScript.py ) . Currently I login to SSH Secure shell client on my windows desktop to access this server and the manually run this script .
MyScript.py
Is there any way , I can run the script remotely from my windows desktop , without needing to login to the SSH Secure sheel client each time .
Yes, there are many ways you accomplish this... if you want to mimic the ssh login and execute the script, you can use pexpect.
I have a simple python script on a Raspberry Pi connected using WiFi that activates an LED. Simple enough.
Is it possible to launch that python script from another device attached to the same network using a simple button in VB.net? Thanks in advance for your help!
You will need to use system call in VB, which run the following command in your PC:
ssh user#rpi:/path/to/command.py arg1 arg2
see this, How do I call a Windows shell command using VB6?.
You will need to run ssh server on the rpi, and possibly set passwordless ssh access using keys.
For ssh on windows, you need either cygwin or putty.