Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

[SOLVED] Problem restarting service via ssh

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
7 posts • Page 1 of 1
Author
Message
humbletech99
Veteran
Veteran
User avatar
Posts: 1229
Joined: Thu May 26, 2005 9:30 am
Location: London

[SOLVED] Problem restarting service via ssh

  • Quote

Post by humbletech99 » Wed Dec 13, 2006 11:44 am

I am trying to ssh into a server to fix it. When I ssh in I can restart the rsyncd dameon just fine via the command

Code: Select all

/etc/init.d/rsyncd restart
But I am trying to do this from a central location via ssh in a script like so

Code: Select all

ssh root@hostname "/etc/init.d/rsyncd restart"
 * Starting rsyncd ...@RSYNCD: 29

@ERROR: protocol startup error
                                                    [ !! ]
and this always fails!

I can't get this to work or even understand why it doesn't. There aren't a lot of env vars in the shell and the script uses only one which shouldn't matter at all if it's present or not (it's at the end of the line so if it's blank it's ok)

Can anybody help out on this?
Last edited by humbletech99 on Fri Dec 15, 2006 6:25 pm, edited 1 time in total.
The Human Equation:

value(geeks) > value(mundanes)
Top
xoomix
Guru
Guru
User avatar
Posts: 489
Joined: Thu Jan 02, 2003 7:30 am

  • Quote

Post by xoomix » Wed Dec 13, 2006 4:34 pm

Works fine for me without the quotes like so:

ssh root@hostname.com /etc/init.d/rsyncd restart


/shrug

Maybe a previous line in your script is horking something up?
Top
James Wells
n00b
n00b
User avatar
Posts: 57
Joined: Fri Sep 10, 2004 4:26 pm

Re: Problem restarting service via ssh

  • Quote

Post by James Wells » Wed Dec 13, 2006 4:47 pm

Greetings,
humbletech99 wrote:There aren't a lot of env vars in the shell and the script uses only one which shouldn't matter at all if it's present or not (it's at the end of the line so if it's blank it's ok)
Right off the bat, this sounds like the issue. When you use ssh for remote execution like that, the remote shell will not read in the users environment, as such, if you require these variables be set, which you make it sound as being required, it will fail unless you force it to read those envrionment settings.
Top
Will Scarlet
Apprentice
Apprentice
Posts: 239
Joined: Fri Mar 19, 2004 7:26 pm

  • Quote

Post by Will Scarlet » Wed Dec 13, 2006 4:50 pm

I find it important when writing scripts to try using the commands within the script from command line. This way you know if the command will even work. Of course there are exceptions to this rule, like branch logic (ie if, case, while, etc...).

Anyway after trying your command from the command line and from within a script, I found that the command works. So, I'm in agreeance with xoomix and James Wells in that something is not right with your script

Hope this helps... :wink:
Top
humbletech99
Veteran
Veteran
User avatar
Posts: 1229
Joined: Thu May 26, 2005 9:30 am
Location: London

  • Quote

Post by humbletech99 » Wed Dec 13, 2006 5:02 pm

I've just tried it without quotes as well. same result.

I've added a command to the ssh string which shows all set vars. This is what the ssh has:

Code: Select all

BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING='set ; /etc/init.d/rsyncd restart'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="16" [3]="1" [4]="release" [5]="i686-pc-linux-gnu")
BASH_VERSION='3.1.16(1)-release'
DIRSTACK=()
EUID=0
GROUPS=()
HOME=/root
HOSTNAME=somename
HOSTTYPE=i686
IFS=$' \t\n'
LOGNAME=root
MACHTYPE=i686-pc-linux-gnu
MAIL=/var/mail/root
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PPID=21531
PS4='+ '
PWD=/root
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
SSH_CLIENT='x.x.x.x 53821 22'
SSH_CONNECTION='x.x.x.x 53821 x.x.x.x 22'
TERM=dumb
UID=0
USER=root
_=bash
and here is what I get from a full ssh shell session

Code: Select all

BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="16" [3]="1" [4]="release" [5]="i686-pc-linux-gnu")
BASH_VERSION='3.1.16(1)-release'
COLUMNS=182
CONFIG_PROTECT_MASK='/etc/terminfo /etc/revdep-rebuild'
CVS_RSH=ssh
DIRSTACK=()
EDITOR=/usr/bin/vim
EUID=0
GCC_SPECS=
GROUPS=()
HISTFILE=/root/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/root
HOSTNAME=somename
HOSTTYPE=i686
IFS=$' \t\n'
INFOPATH=/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/info::/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info:/usr/share/info/emacs-21
LESS='-R -M --shift 5'
LESSOPEN='|lesspipe.sh %s'
LINES=69
LOGNAME=root
MACHTYPE=i686-pc-linux-gnu
MAIL=/var/mail/root
MAILCHECK=60
MANPATH=/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/man::/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PAGER=/usr/bin/less
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.1:/usr/i686-pc-linux-gnu/gcc-bin/4.1.1
PIPESTATUS=([0]="0" [1]="0")
PPID=18490
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
PS2='> '
PS4='+ '
PWD=/root
PYTHONPATH=/usr/lib/portage/pym
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SSH_CLIENT='x.x.x.x 55991 22'
SSH_CONNECTION='x.x.x.x 55991 x.x.x.x 22'
SSH_TTY=/dev/pts/1
TERM=rxvt
UID=0
USER=root
_=
The Human Equation:

value(geeks) > value(mundanes)
Top
Will Scarlet
Apprentice
Apprentice
Posts: 239
Joined: Fri Mar 19, 2004 7:26 pm

  • Quote

Post by Will Scarlet » Thu Dec 14, 2006 9:08 pm

After further research, I found a computer I have that has this issue on. I haven't found the differences as of yet, but I'm still looking.

In the mean time I found this option for ssh:
-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-
based programs on a remote machine, which can be very useful, e.g. when
implementing menu services. Multiple -t options force tty allocation, even
if ssh has no local tty
And it worked quite well.

Something else I found is I can restart many different services from that computer with ssh without issue. In fact rsyncd is the only service tested that has the issue. I find that very odd.

Hope this helps... :wink:
Top
humbletech99
Veteran
Veteran
User avatar
Posts: 1229
Joined: Thu May 26, 2005 9:30 am
Location: London

  • Quote

Post by humbletech99 » Fri Dec 15, 2006 6:22 pm

this did indeed fix it. Thanks!
The Human Equation:

value(geeks) > value(mundanes)
Top
Post Reply

7 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic