Cant get responsive terminal when I ssh from Windows to Linux using putty.exe


 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Cant get responsive terminal when I ssh from Windows to Linux using putty.exe
# 1  
Old 12-21-2019
Cant get responsive terminal when I ssh from Windows to Linux using putty.exe

I ssh from Windows to Linux server and execute a few commands. I have ssh keys setup between them and works fine.

The commands get executed on the Linux server however I wish to stay on the Linux terminal that was opened by putty.exe. However, the terminal simply does the job and closes.

Here is the command I run on Windows:

Code:
C:\putty\putty.exe -ssh -i "C:\putty\my_id_rsa_putty.ppk" myuser@10.8.66.126 -m "C:\putty\ssh_commands.txt"

Here is my "C:\putty\ssh_commands.txt"

Code:
cd /app/axmw/sftp; 
sshpass -p mypass sftp myuser@10.9.88.195; cd Moht; get *; quit; exit
/bin/bash

The job is done and the script gets executed fine on the target Linux, however the Linux terminal gets launch but hangs and is unresponsive.

I need it to be interactive with any shell [bash, sh, ksh] which is not the case.

If i append "-t"at the end of this command like below:

Code:
C:\putty\putty.exe -ssh -i "C:\putty\my_id_rsa_putty.ppk" myuser@10.8.66.126 -m "C:\putty\ssh_commands.txt" -t

Then it gives me interactive shell however it takes me inside the sftp terminal prompt and the commands do not get executed.

How can I get my commands executed and end up landing on interactive bash or any shell on the target Linux ?
# 2  
Old 12-21-2019
Two ideas off the cuff that can't be tested as there's no windows machine within reach:
- run the ssh_commands.txt from within your shell's rc / login file, possibly after a plausibility check
- run / exec your shell at the end of ssh_commands.txt. I see it in your file, but are you sure execution gets to it? The exit in the line before might close the session but leave the teminal window open and unresponsive.
# 3  
Old 12-21-2019
Quote:
Originally Posted by RudiC
Two ideas off the cuff that can't be tested as there's no windows machine within reach:
- run the ssh_commands.txt from within your shell's rc / login file, possibly after a plausibility check
- run / exec your shell at the end of ssh_commands.txt. I see it in your file, but are you sure execution gets to it? The exit in the line before might close the session but leave the teminal window open and unresponsive.
Removed the "-t" argument
Removed the exit from ssh_commands.txt

Ran the C:\putty\putty.exe -ssh -i "C:\putty\my_id_rsa_putty.ppk" myuser@10.8.66.126 -m "C:\putty\ssh_commands.txt"

All good and done however this leaves me with an interactive terminal on sftp prompt instead of a shell.

Same is observed when running ssh_commands.txt directly on Linux host

Kindly suggest.
# 4  
Old 12-21-2019
Hmm. Deleted my response - not helpful.
# 5  
Old 12-21-2019
Post an xtrace of your session, and, upfront, read comments utmost carefully.


Is the exit in your file executed? By which entity (sftp? shell?)?
# 6  
Old 12-21-2019
Quote:
Originally Posted by RudiC
Post an xtrace of your session, and, upfront, read comments utmost carefully.


Is the exit in your file executed? By which entity (sftp? shell?)?
Don't know how to get the xtrace in windows. By the way i modified ssh_commands.txt to debug and i came to the conclusion that "-t" is necessary to us to get the interactive terminal.

The issue with ssh_commands.txt is:

Code:
cd /app/axmw/sftp;    <--- success
touch insidesftp.txt;   <--- success
sshpass -p mypass sftp myuser@10.9.88.195; cd Moht; get *; quit;    <--- Fails (only the first statement gets executed sshpass -p mypass sftp myuser@10.9.88.195; hence i land up on sftp prompt. All the successive commands do not even get executed)
/bin/bash     <--- does not get executed.

Thus, we need to know how to pass each sftp command to be executed.

Last edited by mohtashims; 12-21-2019 at 01:34 PM..
# 7  
Old 12-21-2019
Quote:
Originally Posted by mohtashims
Don't know how to get the xtrace in windows.
The way I read your script I don't think we were talking about xtracing in windows. Set it in your script.


Quote:
.
.
.
Code:
cd /app/axmw/sftp;    <--- success
touch insidesftp.txt;   <--- success
sshpass -p mypass sftp myuser@10.9.88.195; cd Moht; get *; quit;    <--- Fails (only the first statement gets executed sshpass -p mypass sftp myuser@10.9.88.195; hence i land up on sftp prompt. All the successive commands do not even get executed)

Of course, they don't - the sftp command ends with the first semicolon. It expects commands on stdin if having entered "interactive command mode". Did you consider the -b batchfile option?


Quote:
Code:
/bin/bash     <--- does not get executed.

Of course not - you're exiting the script before reaching this statement (in your first post's script, that is)
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Seen Windows pc, having all the features of Linux, could exe, read and edit save like windows

Hi, totally new to linux base using windows when started learning and using computers. but i remember that one pc was there , look alike windows desktop, but could not do the task as windows just click and open and view edit etc. But, you could do a little differently even saving in and opening... (8 Replies)
Discussion started by: jraju
8 Replies

2. Solaris

How to run putty.exe file in server?

Hi, I want to run putty.exe in Solaris server.My main aim is to invoke the putty.exe in Solaris server from a web application(.jsp) deployed in the server so that putty terminal should open. Thanks in advance (11 Replies)
Discussion started by: chaithanyaa
11 Replies

3. Shell Programming and Scripting

Windows exe file fails when triggered from ssh

Hi, I am triggering a windows exe file using the below command. ssh user@remoteserver command.exe -option1:xx /option2:yy This command is working fine from windows command prompt. When I am triggering the same command from ssh I get the error message cant load Any ideas to deal with... (2 Replies)
Discussion started by: ahmedwaseem2000
2 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Is it possible to use PuTTY psftp.exe to move file from one directory to another?

Hello All, I am running a script (power shell) from my desktop (Windows). The script needs to sftp a file(using PuTTY psftp.exe ) from my desktop to a server(UNIX server). Then, as a second step, the script needs to move (or copy and delete) this file from one directory on the server (UNIX server)... (3 Replies)
Discussion started by: scampi
3 Replies

5. Linux

Help!! trying to connect to linux SSH from windows putty client

Hi, i am trying to connect my Putty session on a windows box to a linux SSH, i have generated private and public key pairs using puttygen, i have set the public one to be in an OPENSSH format... and have put this in my authorized_keys file in linux, when i connect i get the following errors: ... (1 Reply)
Discussion started by: Jtyreman
1 Replies

6. UNIX for Dummies Questions & Answers

startX windows application during boot.....putty connection takes the windows

Dear all i am new to linux/debian i run my application on the computer...during startup in bashrc i wrk wid dis script to invoke startx..i do this above command and it works perfectly... if && ; then startx -- -br 1>/dev/null exit 0 fi i use winscp for file transfer and putty for... (1 Reply)
Discussion started by: venkat_330
1 Replies

7. UNIX for Dummies Questions & Answers

vnc over an ssh tunnel Linux to Linux to Windows

I *think* what I want to do is not only possible but easy, but as a "dummy" :) I can't figure it out. Here's what I have: Linux (Ubuntu 10.04) laptop that is not in my house, but has an Internet connection. Linux (Ubuntu 9.04) computer in my house that has unfettered access to the... (6 Replies)
Discussion started by: WesleyC
6 Replies

8. Windows & DOS: Issues & Discussions

looking for linux like tab terminal for windows

Hello all is there any free tool like linux tabbed terminal but for windows im used to work with putty and its great but i wander if there something like putty but with tabs thanks (12 Replies)
Discussion started by: umen
12 Replies

9. Red Hat

How to take printout of linux file from windows xp using putty?

Friends, I have installed Putty in my windows xp pc. I am connecting the RHEL AS 3 server using putty from my windows xp. My printer is connected to my windows xp. Now, i want to print text.txt of RHEL AS 3.0 in my windows xp printer through putty. For Example: my pc ip is 117.23.2.55... (3 Replies)
Discussion started by: sathyguy
3 Replies

10. UNIX for Dummies Questions & Answers

mac 10.4>terminal>linux remote server>ssh login accepted>session closed-why?

mac 10.4>terminal>linux remote server>ssh login accepted>session closed-why? AHHHH!! I have been connecting to the server with the line: ssh userid@website.com The remote server accepts my password; logs me in with ssh; posts a lovely welcome message AND closes the session. Is this a "term... (0 Replies)
Discussion started by: xprankard
0 Replies
Login or Register to Ask a Question