SSH gateway throught linux jumphost - ssh

From a host with Windows server 2019, you need to connect via http & rdp to hosts on another network. Is it possible to establish a connection using standard Windows tools through an ssh gateway from which there is access to the destination network? Not to one host, but to all hosts on the subnet.

Batch file starts then user logon:
#echo off
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d socks=127.0.0.1:8888 /f
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 00000001 /f
ssh -D 8888 %username%#ip.ssh.tun.nel

Related

Setup ssh_config with proxies when AllowTCPForwarding is not allowed

How can you write the following setup in an ssh config.
### The Bastion Host
Host bastion-host-nickname
HostName bastion-hostname
### The Remote Host
Host remote-host-nickname
HostName remote-hostname
ProxyJump bastion-host-nickname
### The Remote Host VM
Host remote-host-vm-nickname
Hostname remote-vm-hostname
????
I have a bastian sever through which my remote-host can be reached via ssh. This connection is working as expected. On my remote-host there are a few virtual machines (the remote host vm) that can also be reached via ssh.
AllowTCPForwarding is disabled in the sshd_config of the remote-host. Therefore neither an SSH tunnel nor a ProxyCommand can be used. With both you get the error message "... administratively prohibited". The sshd_config should stay that way.
My preferred approach is that I connect to the remote-host and execute the following command:
[#remote-host]
"ssh -t -i keyfile user#remote-vm-hostname \" whoami \ ""
How can I describe this ssh command in my ssh_config?
Especially so that this ssh command can only be executed on my remote host.

SSH server and localhost

I tried to install a SSH server on WSL, it never worked. So i installed my SSH server on my laptop and i try to connect, it doesn't work either. But it works from my phone on 4G or everything expect my computer on local
I get this error everytime, either with WSL Debian ou Windows :
ssh: connect to host localhost port 22: Connection refused
Check first this OpenSSH Windows installation guide:
It includes a network configuration:
Allow incoming connections to SSH server in Windows Firewall:
When installed as an optional feature, the firewall rule “OpenSSH SSH Server (sshd)” should have been created automatically.
If not, proceed to create and enable the rule as follows.
Either run the following PowerShell command as the Administrator:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\System32\OpenSSH\sshd.exe"
Replace C:\System32\OpenSSH\sshd.exe with the actual path to the sshd.exe (C:\Program Files\OpenSSH\ssh.exe, had you followed the manual installation instructions above).
or go to Control Panel > System and Security > Windows Firewall1 > Advanced Settings > Inbound Rules and add a new rule for port 22.
Then you can check if at least your SSH daemon can receive anything.
The OP SRP adds in the discussion:
The problem turned out to be other machine with same IP address as the server."
I cheated and it works: I used a VPN.

Batch file to get HTTP/S webserver info

I am looking for a batch script file which will automatically telnet to a user input website on port 80 and 443 and get us the Server: value (Info).
Below script:
telnet -f ip.txt %ip% 80
GET / HTTP/1.1
Host: %ip%
for /F "delims=" %%c in ('type ip.txt ^| findstr Server:') do set server=%%c
This script does the job but need to enter Ctrl+C to close the session, I need something which will automatically close the connection and get me the output.
I also require help with openssl.exe with the same requirement to check TCP 443 (HTTPS) websites.
Using openssl.exe, I need loop or nested for checking sslv3, tls1.0 - 1.2. Any help with this is highly appreciated.

Plink never completes a private key ssh connection, doesn't timeout, key isn't refused. Putty works fine

My ultimate goal is to use MyEnTunnel to set up a tunnel between a Windows server at location A, and a BSD machine at location B so that I can access a database server running at location B locally at A. (localhost:3054 ======> bsdmachine:3050) MyEnTunnel is essentially a Windows Service wrapper for plink.
We use a private key for ssh access at location B. PuttyGen was used to convert the private key into a .ppk file to be compatible with putty, plink, etc. Putty connects to the BSD machine using the .ppk with no problems whatsoever.
I copied the command line string MyEnTunnel is using to establish the connection, pasted it into a directory with the latest version of putty, plink, etc. (in case MyEnTunnel's plink.exe is outdated), and it still failed.
plink.exe 192.168.0.233 -N -ssh -2 -P 916 -l "root" -C -i "keyfile.ppk" -L 3054:192.168.0.208:3050
The BSD machine has several jails running; 1.233 is the host, and accepts SSH connections. 1.208 is a jail with a server listening to 3050, and will not accept ssh connections.
I use tunnels so rarely, I always forget the proper order of things, and when I'm supposed to ur -R and -L, so I tried the 16 possibilities. ;-) I then started plink with the bare options:
plink.exe 192.168.0.233 -N -ssh -2 -P 916 -l "root" -i "keyfile.ppk"
Putty, with these settings, connects without a hitch. Plink reports:
Using username "root".
And proceeds to do nothing forever.
What am I doing wrong, and what would establish the tunnel with the local listening port 3054, and the target port 3050 at 192.168.0.208?
You used the -N flag, this makes it run on the background. If you add the -v flag you can see all the activity of the forward/tunnel.

how to visit every computer on the network and modify the host file in windows xp

We need to append a line to the hosts file for every user on our network. I have admin privileges, but don't know the first thing about windows scripting. Can someone point me in the right direction on this? I don't have the list of all the machine names, so I'd prefer a script that would discover all the machines on the network and do the update.
You can do it by batch file:
for %%x in (%0) do set BatchPath=%%~dpsx
for %%x in (%BatchPath%) do set BatchPath=%%~dpsx
FOR /F %%i IN (%BatchPath%\devices.txt) DO copy /B \\%%i\C$\WINDOWS\system32\drivers\etc\hosts + %BatchPath%\hostline.txt \\%%i\C$\WINDOWS\system32\drivers\etc\hosts /y
devices.txt is a text file with your machine names:
machinename1
machinename2
hostline.txt is a text file containing per example:
127.0.0.1 localhost