Detach program from SSH connection on a windows - windows

I need to log in to a Windows server via SSH through a local Python (2.7) script, start a script on the server and then disconnect the SSH connection, so that the local script can continue to run.
As of now, I am using fabric, and the local script will not continue before the remote script is done and the SSH connection is closed.
I have read on a range of forums, but it seems to my (admittedly inexperienced) eyes that most replys use unix commands. I need to be able to log onto a windows machine however.
What can I do?
Thank you very much in advance!

Does this help you? You can write a batch script that'll start in the background:
Running Windows batch file commands asynchronously

Related

Downloading large file on remote host. Then close ssh connection

I am trying to download a stackoverlfow dump of all posts to a remote server (actually a container on a remote host). Now as you can image the dump is large (11G). I want to start a download and then be able to exit my SSH connection to the remote host.
I have looked at tmux but it's confusing.
I know wget https://archive.org/download/stackexchange/stackoverflow.com-Posts.7z will work but I will have to stay connected for the duration of the download.
Does anyone know how I can use tmux to solve this problem?
If I've correctly understood you situation, using nohup to launch the command will do the trick.
nohup wget https://archive.org/download/stackexchange/stackoverflow.com-Posts.7z
This will prevent the killing of the wget process when the shell terminates.
You can connect via SSH, execute the above command and exit. It will keed downloading by itself.
By the way: Tmux stands for Terminal Multiplexer and it's not related to the life cycle of a process.

How to exit from ssh session and execute commands on the last shell from a shell script?

I'm trying to write a small shell script. It should exit from the current ssh session but after that execute commands on my local computer. I don't know if thats even possible. The situation is the following: I modify a project, test and build it on my buildserver. When I start the script I would be on my buildserver and I would have modified and tested the project. Now I want a script to speed of the process of compiling the project and installing it on my local computer. To do this manually I would basically do something like the following:
user#buildserver:~$ ./build project
user#buildserver:~$ exit
user#localcomputer:~$ scp buildserver:/home/user/project/binary /tmp
user#localcomputer:~$ /home/user/install /tmp/binary
The only thing I got working so far is to exit from the ssh session by calling logout in s shell script.
A script running on a remote computer you’re connected to through SSH cannot execute commands on your computer without making a further SSH connection to your computer (which may not be an option if you’re behind a NAT or do not have an SSH server running).
A possible alternative may be to have a script on your computer that runs the shell script on the remote computer through SSH; once that remote script has finished, the local SSH client will exit and your local script can continue exiting whatever local commands are desired.

Shell Script program to download files from linux remote server

I am very new in shell scripting , i want to download some files from linux remote server ,so how can i proceed for that.That remote server is ssh based .
first of all, ftp service is better choice to get files from remote server.
If only sshd service is available, then you may use ssh based command sftp or scp.
However, using sftp or scp commands will invoke an interactive password prompt, which is a problem in shell script --> You have to ask for help to expect command. see Automate scp file transfer using a shell script .
Besides expect, you may also set up trust relationship between two servers, then you may use scp without password. See http://www.linuxproblem.org/art_9.html

how to call a script in the remote machine without using ssh

I have to run a shell script which is on a remote machine from the script on my local machine.
I thought of using ssh in my script but it would prompt for password which does not help as I will need to make this script run as a cronjob.
Could anyone just guide me like what would be ideal to use rather than using ssh to connect to the remote machine and run the script present there.
First of all you can set up passwordless ssh connections using private keys (that's what I should do).
If that's not an option, well there is expect, and here's an old but working tutorial.

how to connect to a remote server using ssh and getting the information

I'm trying to write a shell script using bash. I have multiple servers and each servers have multiple apps runnings on it. Each server also has specific app scripts to check/stop/start etc. All I want to do is that, do a ssh and connect to the remote server.
Which I'm also able to do sucessfully and exceute the commands also..
In some instance I need to check some process status on a remote machine, the app sepecific scripts already does that. But using my ssh when i try to execute that script I dont get any info ( it gets executed but no info is passed ). How do i get the information from the remote host and display on the local host here.
Any help on this is really appreciated.
Regards,
Senny
You can run remote commands and get results locally by passing the command as a string to ssh.
In your script, you can do:
CMD_OUT=$(ssh user#remote_host "/path/to/script argument")
The command will be run remotely and the output store in the CMD_OUT variable. You can then parse the output in your script to get the results you want.
To simplify usage of your script, you might want to set up passwordless ssh so you don't have to type your password each time the script tries to run a remote command.

Resources