Posts

Showing posts with the label Ssh

Access Host's Ssh Tunnel From Docker Container

Answer : Using your hosts network as network for your containers via --net=host or in docker-compose via network_mode: host is one option but this has the unwanted side effect that (a) you now expose the container ports in your host system and (b) that you cannot connect to those containers anymore that are not mapped to your host network. In your case, a quick and cleaner solution would be to make your ssh tunnel "available" to your docker containers (e.g. by binding ssh to the docker0 bridge) instead of exposing your docker containers in your host environment (as suggested in the accepted answer). Setting up the tunnel: For this to work, retrieve the ip your docker0 bridge is using via: ifconfig you will see something like this: docker0 Link encap:Ethernet HWaddr 03:41:4a:26:b7:31 inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0 Now you need to tell ssh to bind to this ip to listen for traffic directed towards port 9000 via ssh -L 1...

Adding Password To .ssh/config

Answer : Solution 1: No, There is no method to specify or provide on the command line the password in a non-interactive manner for ssh authentication using a openssh built-in mechanism. At least not one what I know of. You could hardcode your password into expect script but it is not a good solution either. You definitely would want to use keypairs for passwordless authentication as Michael stated, in the end private key is pretty much a big password in the file. Solution 2: To avoid the string of comments: Yes, this is insecure (not even arguably insecure). I would strongly recommend you only do it in a lab situation on an isolated network or a similiar situation that does not involve production servers or potentientially production server without a full reset/format. I wanted to set this up as I don't think my 2950 switch supports private/public keys and I hope at some point to get that knowledge, but I am not there yet. Using an alias and sshpass this can be acc...

Create A Batch File Or Shortcut To PuTTY (ssh) That Opens A Session And Runs A Command

Image
Answer : Use the commandline PuTTY version plink.exe to initate a SSH connection to a host of choice. Use the -ssh switch to connect with SSH. With the -m switch you can include a command file: plink.exe -ssh host1 -m C:\path\to\commands.txt You can download plink.exe from here. Last step would be to create a shortcut including plink.exe with the desired parameters. Check out the Plink documentation for other various parameters: Plink.exe documentation To automate a command execution, use Plink (from PuTTY package), not PuTTY itself. Plink accepts a command on its command line: plink.exe user@host command If you want to keep using PuTTY, you can use -m switch to specify a command file (Plink supports the -m switch too). You can use putty configurations to achieve this. Load putty and configure your session. Enter the remote command that you'd like to run here: Then, before clicking " Open ", go back to the " Session " tab (at the top), and save your co...

Connecting To Remote SSH Server (via Node.js/html5 Console)

Answer : This is easily doable with modules like ssh2 , xterm , and socket.io . Here's an example: npm install ssh2 xterm socket.io Create index.html : <html> <head> <title>SSH Terminal</title> <link rel="stylesheet" href="/src/xterm.css" /> <script src="/src/xterm.js"></script> <script src="/addons/fit/fit.js"></script> <script src="/socket.io/socket.io.js"></script> <script> window.addEventListener('load', function() { var terminalContainer = document.getElementById('terminal-container'); var term = new Terminal({ cursorBlink: true }); term.open(terminalContainer); term.fit(); var socket = io.connect(); socket.on('connect', function() { term.write('\r\n*** Connected to backend***\r\n'); // Browser -> Backend term.o...