Re: ssh and su



GaGadget wrote:

Kimmo Koivisto wrote:

GaGadget wrote:

I would like to be able to launch command as root on distant machines
using ssh.

Any idea or tips on that one ?

I would do this using sudo instead of su.

1. create user1 to the remote machine

2. define commands that user1 can execute as root to the /etc/sudoers
<example entry to the sudoers file>
user1 ALL=NOPASSWD:/sbin/iptables
</example>

Unfortunatly, I am not allowed to use sudo ...


3. execute command as root using ssh
#ssh user1@xxxxxxx "sudo -u root /sbin/iptables -L -n"
<no root password needed>

4. to execute ssh without user1's password, create RSA/DSA-keys for you
and store public part to the /home/user1/.ssh/authorized_keys to the
foo.bar machine

Yes, I'll do that for preventing the user1 password prompt.

Regards
Kimmo Koivisto

I will try to use "-t" with the ssh command as suggested by Darren on an
other post.
"su" seems to need a real pseudo-tty and the "-t" force the allocation of
a pseudo-tty not allocated by default when ssh is used force launching
remote command.

Thank you for the complete answer guys.

Gaga.

It works great !

Thank you,
Regars.
.



Relevant Pages

  • Remote Execution of sudo Command Hangs.
    ... One is trying to use ssh and sudo to ... If you run it via ssh from a remote system, however, it ... Reading the expect manual shows an exit command but also ...
    (freebsd-questions)
  • Re: help with text-append over SSH ? - dd: unknown operand >>
    ... I have an account on a system where I cannot log in over SSH, ... But again, file2 is remote, and I can't log in there... ... access to the 'echo' command and the 'dd' command on ... Then you are not running a 'standard shell', but some sort of local ...
    (freebsd-questions)
  • Re: How can I start a GUI application through SSH
    ... >> I would like to be able to start an X application through ssh. ... >> app to actually run on my local box (meaning I want the window to pop up ... > For the purpose of this discussion, the 'server' is the remote system the ... > If you want to learn more, you should read up on the xauth command. ...
    (freebsd-questions)
  • Re: Setting env variable via ssh
    ... from a bash command line, I want to invoke a remote ... before I can I invoke ... on the remote machine. ... How do I connect to the machine via ssh, set the environment variable and finally invoke ...
    (comp.unix.shell)
  • help with text-append over SSH ?
    ... remotely, over SSH. ... the contents of a remote text file, ... I have access to the 'echo' command and the ... 'dd' command on the remote host ... ...
    (freebsd-questions)