All Questions
Tagged with shell-script ssh-tunneling
13 questions
1
vote
1
answer
473
views
Saving the dynamically allocated port of SSH tunnel
There is already a great question and answer here, but I have a different case.
I create a tunnel with the following command:
$ ssh -N -R 0:192.168.0.16:80 [email protected]
Allocated port 35007 for ...
2
votes
1
answer
2k
views
Command not found when executing in remote server using shell script
I am trying to automate a few steps that I need to execute in a remote linux machine from my local ubuntu computer.
My shell script is as follows :-
#!/bin/sh
ssh XYZ '
qlogin -l cuda=1
'
When I ...
1
vote
1
answer
689
views
How to run a local script with whitespace in arguments on a remote machine through multiple SSH?
Similar to my question here, except with multiple ssh, and similar to this question but with white space in the arguments...
I would like to run a local script, test.sh, on a remote server via ...
0
votes
1
answer
353
views
Automate SSHing into multiple connections with script
I want to ssh through three different servers. First one uses a password, second one doesn't and the third and final one has a different password than the first. Only the first one needs a username.
...
1
vote
1
answer
386
views
setup consistent tunnel between two hosts wirh dynamic IPs
I would like to setup a constant ssh tunnel between two hosts. Now it becomes tricky as both hosts may change their IPs (not at the same time though). My idea to overcome this is to have two reverse ...
3
votes
1
answer
3k
views
Use bash EXIT trap to confirm or cancel ctrl+d [duplicate]
Is there a simple way to require confirmation before logging out of a shell, and to prevent the shell from exiting if confirmation is denied? This would be useful to avoid accidentally terminating an ...
0
votes
1
answer
1k
views
Probe SSH connection and detect ssh disconnect or logout
I'am running a script to connect to another host (via ssh) and it's doing some deployment work.
I need to detect the ssh connection is closed/or interrupted, then need to execute a command to delete ...
3
votes
1
answer
1k
views
How to avoid piping awk to awk?
I have written the following script, which runs from my user's crontab, parses ~/.ssh/config for SSH port forwards, and automatically connects them if the Host line ends with "remote," "local," or "...
4
votes
1
answer
2k
views
Predicting the PID of previously started SSH command
This is the weirdest thing.
In a script, I start an SSH tunnel like so:
ssh -o StrictHostkeyChecking=no -fND 8080 foo@bar
This starts an ssh instance that goes into the background, and script ...
3
votes
1
answer
313
views
Programmatically / dynamically adjust SSH session port forwards
I have a workflow where I am trying to do the following:
For a given existing SSH session, access the remote machine and perform a process from which a port is returned (e.g. a remote daemon has ...
2
votes
1
answer
1k
views
Cron job running but not establishing tunnel
I have a script which establishes a reverse tunnel on an endpoint HostB. It looks like this:
cat tun.sh
#!/usr/bin/env bash
# Test code
/usr/bin/ssh -V 1> /home/userA/bin/tun.stdout 2> /home/...
19
votes
5
answers
6k
views
Determine dynamically allocated port for OpenSSH RemoteForward
Question (TL;DR)
When assigning ports dynamically for remote forwarding (a.k.a. -R option), how can a script on the remote machine (for instance sourced from .bashrc) determine which ports were ...
7
votes
1
answer
14k
views
start autossh reverse tunnel automatically when network comes up
I connect from my home PC thru an Internet server I own to a restricted client (that I also own) using a reverse ssh tunnel.
I have a script that sets up the restricted client to middleman leg of ...