Question about SSH
Hello,
I'm trying to make either a single command or a shell script that I can run that will SSH into another box, login as root, then execute a shell script on the remote box. I've been trying to make one, however I've been unsuccessful so far. Any suggestions? Much appreciated! |
If you just want to run a command as root (i.e. without logging in and running .bash_profile) then sudo's probably the easiest way:
Code:
ssh user@server.domain sudo command You can't run su from the ssh command-line, because it needs a terminal of some sort. You could create a virtual terminal, then attach it to the standard input and output streams provided by sshd, but that's much more work than the sudo route. Hope that helps, —Robert J Lee |
You could also setuid your script and run it as an unprivileged user. This avoids the security problem of allowing your account to gain root on that server without a password, but that means you need to be super careful about who can write to that script.
|
All times are GMT -5. The time now is 11:16 PM. |