1

I'm remote connecting to a linux machine from windows using PLINK and would like to execute some commands in a batch script right after connecting, but it seems I cannot keep the terminal alive.

After reading this little nugget here, I thought that a -t flag would suffice, but that didn't work.

plink my_username@123.456.789.10 -pw my_pass -batch -t "cd /home/app/"

2 Answers2

1

If you specify a command on plink commandline, it will ask the SSH server to execute that command and exit. If you want to start shell afterwards, you have to start it explicitly.

If you want to keep using Plink interactively, you probably want to add the -t switch to allocate a pseudo terminal. You will also want the --no-antispoof switch.

plink user@host -pw password --no-antispoof -t "cd /home/app/ && /bin/bash"

A similar question about PuTTY:
How to run a remote command in PuTTY after login & keep the shell running?

0

Try using KiTTY instead of PuTTY. KiTTY is a fork of PuTTY that - among other features - has a "login script" feature which allows to run certain commands automatically after login (and then keep the terminal open).

raj
  • 2,245