soField
soField

Reputation: 2696

How to force ssh to execute bash instead of the user default on the remote machine?

I want to execute a bash script with ssh but when I try this it's using ksh which is the user's default shell.

I can't change that default.

So, how can I trick ssh to execute my script with bash instead of the default shell?

Upvotes: 0

Views: 3879

Answers (2)

Alok Singhal
Alok Singhal

Reputation: 96191

Make this the first line of your script:

#!/usr/bin/env bash

Edit: As per this, the utility of /usr/bin/env is dubious. So, you probably want:

#!/bin/bash

Replace /bin/bash with the actual path of bash executable.

Upvotes: 5

tangens
tangens

Reputation: 39743

You can call your script explicitly with bash:

ssh <ssh-opts> bash <scriptname>

This way there will be a ksh executed at login, but inside ksh you start a bash executing your script.

Upvotes: 3

Related Questions