Search code examples
linuxsshsudosu

sudo su - immediately after SSH


I have this SSH config file for root:

User    ansible
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
PermitLocalCommand yes
LocalCommand='/bin/sudo /bin/su -'
IdentityFile    /root/.ssh/ansible_onlinux

(FYI I've tried with ' " without anything, same issue) When I ssh to the server I got this error.

/bin/bash: /bin/sudo: No such file or directory

However if I run the command on the machine it works. Where is the problem?

I want to ssh from my ubuntu on windows (WSL) to a centos server.


Solution

  • This is the working config.

    User    ansible
    IdentityFile    /root/.ssh/ansible_onlinux
    UserKnownHostsFile=/dev/null
    StrictHostKeyChecking no
    LogLevel=error
    RequestTTY force
    RemoteCommand sudo su -