LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-07-2009, 04:48 PM   #1
ac1115
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
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!
 
Old 08-07-2009, 06:26 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
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
I just tried that on my Ubuntu box, and it worked - although it did print the admin password the second time. You could always configure sudo to allow the user to run the specific command without a password.

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
 
Old 08-07-2009, 06:45 PM   #3
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh question tronica Linux - Server 3 06-24-2007 07:27 AM
ssh-agent/ssh-add question mega Slackware 2 01-26-2005 03:09 AM
SSH Question JockVSJock Slackware 2 11-11-2004 07:00 PM
Question on SSH ? brokenflea Slackware 7 10-27-2004 09:25 AM
question about ssh minor Linux - Security 7 05-20-2001 08:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration