Ubuntu – Running a bash script from Putty on a remote server

bashputtysshUbuntu

I was advised to post here after my question was closed on Stack Overflow.

I'm trying to run a bash script on a remote server using Putty over SSH. I'm on a Windows 10 machine and the script is saved on the server. It's an interactive script so I need to be able to enter some data after the script is run.

This is what I've tried so far:

1) Log in via Putty

2) Navigate to the directory where the script is saved

3) Enter the command

sh scriptname.sh

At this point Putty returns the message:

forbidden command: sh

What am I getting wrong? Is Putty the wrong tool for what I'm trying to do?

I've already talked to the admin about it and he claims to be able to run the script from a normal user account, but he wasn't of any help otherwise.

Best Answer

Based on the output forbidden command: sh your ssh account are set to lshell as a shell. Basically it's purpose to limit commands to a very small set. So you can't run your script from it. Even if you do, most likely it will fail because command set are very restricted.

There is no regular way to run scripts from lshell. You can try asking your admin to change your account shell to bash if it is possible to run custom scripts.