When I login using ssh command to remote server Linux VM-0-16-centos 3.10.0-1160.31.1.el7.x86_64 #1 SMP Thu Jun 10 13:32:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux and execute env command, I can find the following environment variable:


But when I login through GitHub Actions like this:

- name: Restart server
  uses: appleboy/ssh-action@master
    host: ${{ secrets.BINGQIAN_HOST }}
    username: ${{ secrets.BINGQIAN_USER }}
    password: ${{ secrets.SSH_BINGQIAN_PASSWORD }}
    script: |
      cd /opt/apps/pydolphin
      nohup /opt/apps/pydolphin/tencent-cloud-start-app.sh &> schedule.log &!
      sleep 20

It could not find the environmnet config ENV=TENCENT, what the difference between the two ways to login? I am using the same user to login. I set the env in .zshrc like this:

  • 2
    The first probably starts a login shell that reads your configs, the second one does not
    – Panki
    Jul 28, 2022 at 14:11
  • Can you explain what part of your manual ssh session sets the ENV environment variable? If it's set by the software that's connecting to your remote server, then it looks like your Github Actions config does not duplicate that behavior. If it's set by some script or command that happens in the remote server, will that script/command recognize the connections from Github Actions needs to have the same setting as your manual ssh connections?
    – Sotto Voce
    Jul 28, 2022 at 14:24

1 Answer 1


I'm not a zsh expert, but I found this reference in the zsh man page:

If the shell is a login shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc.

There's more both before and after that part, and another part of the man page indicates that $ZDOTDIR defaults to the user's home dir.

The essence is that when the login session is not interactive, the zsh shell will not invoke the commands in the ~/.zshrc file. Your manual ssh connections are interactive and the ones from Github Actions are not interactive, so the command to set the ENV variable is not invoked when Github Actions makes the connection.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .