title: telnet through SSH
body: <p>I need to connect a remote computer via ssh and then make a telnet connection to its port </p>
  
  <blockquote>
    <p>(telnet localhost #port)</p>
  </blockquote>
  
  <p>with JAVA</p>
  
  <p>I tried some libraries (sshd, ganymed) and succesfully login to remote computer but cannot login to telnet. The problem is that the libraries open a ssh connection and run <strong>"one"</strong> command at a time. However telnet login is interactive. It asks for username then i'm writing it to stream (with EOF) but hangs there forever</p>
  
  <p>I cannot find a proper way for implementation. Any advice?</p>
  
  <p>(using linux)</p>