How can I get telnet to work successfully in Gitbash? - windows

I am trying to run telnet in gitbash on windows, but when I enter the command telnet, I just get returned to my command line. I already enabled the telnet client like the link at the bottom of this question explained.
The problem now is that when I type telnet into gitbash, nothing happens, and I am just returned a new command line. If I open up a windows shell and type telnet then it runs as expected, which leads me to believe it's an issue with gitbash.
How can I get telnet to work successfully in Gitbash?
Link to a similar question, but only explains how to enable the tcp client, not how to get gitbash to run it: Can not use command telnet in git bash

I don't think that git-bash is meant to run such programs. It may be possible to do so, but it only contains minimal utilies, often useful to manage your repositories.
If you want extended unix-system on windows, use a VM or Windows Subsystem for Linux (often called bash on windows).
If you just want to run the windows telnet program from git bash, you can simply write the path to it, eg C:/Users/Documents/telnet/telnet.exe

Just to complement #NanoPish's answer, telnet need to be invoked with winpty(for those who used MinTTY as terminal emulator) on git bash to work.
Example:
MINGW64 ~
$ which telnet
/c/WINDOWS/system32/telnet
MINGW64 ~
$ winpty telnet localhost 2181
Zookeeper version: 3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT

Related

How to login into ssh on windows cmd prompt

I am trying to login into one of the ethernet ports on my development board on ssh from my Windows pc. But it is displaying a message like
'ssh' is not recognized as an internal or external command when i tried to loging into it using ssh root#192.168.4.14.
How to get ssh into my windows system?
I use Linux Bash on my windows to use ssh.
You can install it from your windows configurations. But I think it is only for Windows 10 64bits.
Or if you want, you can install git desktop application. From this you can use linux commands into the git bash.
You can use the below command in command prompt to initiate ssh session.
ssh -l username 192.168.1.1

How to get bash ssh server started from psexec or user-logon script in windows 10

I have a W10 machine with bash set up. If I open a cmd window and type bash -i I can get to a bash shell no problem. However, if I enter the W10 machine using psexec and the same user and type bash -i, everything just hangs.
I know I can and do use an Ubuntu ssh server to get in, but I can only do that if the Ubuntu ssh server is running. It only seems to run if there is at least one bash session active. I thought I could use the psexec entry as a backup and start the Ubuntu ssh server or do anything else, but from the psexec cmd window, I cannot get to bash. When I type bash -i everything hangs and I need to close the cmd window on the remote machine.
The same problem occurs if I use a windows ssh server. I can get to a cmd window, but everything hangs if I type bash -i.
I also tried the Windows task scheduler to try to start the Ubuntu ssh server at a user login, but that also just hangs.

can not issue any command on freesshd server

I installed FreeSSHd server on my Windows XP machine. Then i started FreeSSHd and created a user. After that i runned Putty to connect my newly installed SSH server. I entered my created user name and password in putty. I successfully logged on but i couldn't execute any SSH commands with putty. Only HELP and DIR commands answer properly. Other SSH commands like LS, PWD, etc. returns error message such as "xxx command is an unknown command and can not be executed.".
My question is simple. How can execute SSH commands via Putty over FreeSSHd server on Windows machine. I want to simulate a file copy. I think i should execute SCP or PUT commands but i couldn't success.
Any ideas?
Commands like "ls" and "pwd" aren't "ssh commands", they're Unix commands. You'd expect for them to be available a Unix system (including Linux). MS Windows isn't a Unix system and doesn't provide those commands.
You can install these programs as third-party software if you like. Cygwin is a popular free package.

single line telnet commands using terminal

I need to pull something along the lines of "telnet root#192.168.2.99: irinject BACK"
however this refuses to work. There is no password required.
What is the correct syntax to perform this task using the terminal on Ubuntu 11.10?
If you absolutely must do it this way, use echo or etc. to pipe commands to the telnet session — and be ready to reinstall machines as they get hacked.
Strongly preferred is to use ssh with key access; you can even include the command that way.
ssh -i path/to/root-key root#host command

How to create SSH tunnel using PuTTY in Windows?

I need to create SSH tunnel with PuTTY in Windows, that would do the same as this command in Linux:
ssh -fN -L 2000:SomeIp:2000 myusername#myLinuxBox
I tried many options in PuTTY, including setting source port in GUI to "2000" and destination to "SomeIp:2000". Destination is set to local (as the -L switch suggests).
I successfully login to my SSH box but port forward is not made.
Is this even possible in Windows, so that all the connections made by programs that use this port (2000) will go through this tunnel?
With the PuTTY suite, you can set up a tunnel either using the PuTTY itself (GUI) or using the command-line tool plink.exe.
With the plink.exe, you use the same arguments as with the OpenSSH ssh, except for the -f, which does not have an equivalent in Windows.
plink.exe -N -L 2000:SomeIp:2000 myusername#myLinuxBox
Reference: Using the command-line connection tool Plink
With the PuTTY, the -L 2000:SomeIp:2000 translates to:
So it's actually, what you claim to have tried. If you have any problems, use the PuTTY event log to investigate:
The -N translates to the option "Don't start a shell or command at all".
But it probably does not make sense with a GUI client to enable it, as you get a window anyway, you just cannot do anything with it. See also the PuTTY wish no-terminal-window.
If you are going to use the tunnel to connect with PuTTY to another server, you can actually set up the tunnel as a part of the session settings with use of plink as a proxy, see: PuTTY configuration equivalent to OpenSSH ProxyCommand.
You probably want to use plink.exe instead of the GUI client. The command line syntax is compatible iirc.
Or you can wade through the putty GUI, which also allows this. See Connection > SSH > Tunnels on the left side with the option tree.
The answers above mention two different ways of resolving the problem:
using plink
using putty GUI
I don't have plink and I can't download the plink.exe file (it is a closely monitored restricted environment) so used a different way to script the solution with a one-line script:
start putty -ssh myusername#myLinuxBox -pw my_pw -L 2000:localhost:2000
Store this in a batch file (file extension ".bat", e.g. "tunnel.bat"). So every time you double-click on this file the command is run and putty creates the ssh tunnel. If you want more tunnels just repeat this part
-L 2000:localhost:2000
by changing the ports accordingly.
"Source" port is a port number on the same machine from which you are running putty (eg. open this in your browser: 127.0.0.1:source). "Destination" is your remote port that you want to connect to from your local machine. It started to work after I realized this.

Resources