开发者

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

开发者 https://www.devze.com 2022-12-19 07:29 出处:网络
I want to execute a bash script wit开发者_开发知识库h ssh but when I try this it\'s using ksh which is the user\'s default shell.

I want to execute a bash script wit开发者_开发知识库h 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消