LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-25-2007, 09:29 AM   #1
tuxhats
Member
 
Registered: Dec 2005
Location: Austin, Texas area
Distribution: I have multiple Distos available, but I mostly use Ubuntu.
Posts: 47

Rep: Reputation: 16
Question How do I get a local(client) reboot (init 6) when a ssh connection is closed?


How do I get a local client to reboot(init 6) when a ssh connection is closed? I think I must modify the local ssh_config or sshd_config.
What I am looking for, is a way to force a local client to reboot(init 6) when a ssh session ends. Perhaps there is a better way, script, or cron to accomplish this.

Alright, here's the bit. I have rewritten a Knoppix LiveCD to boot into only an "init 1" environment(init 6 and init 0 are also available). When a client, using this LiveCD, secure shells(ssh) onto a remote server, and then exits "this ssh session", I wish to have the LiveCD reboot (init 6).

Thanks in advance! ...... I know this is a hard one for the community to solve.... A challenge.

Last edited by tuxhats; 08-25-2007 at 03:42 PM.
 
Old 08-25-2007, 06:40 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
I know this is a hard one for the community to solve.... A challenge.
If you boot into runlevel 1, and have no option to go to 3-5, then no, not really. No network, no SSH. There you have it ;-p All fun aside you could move the 'ssh' binary to another location and replace it with a wrapper shellscript that executes the commandline and then does a 'sudo /sbin/shutdown -r' the box. Can't imagine why you would want to make it reboot though. If you don't script exceptions or a choice then reboot will happen on *every* ssh session exit, even where it failed to connect to a system due to whatever reasons.
 
Old 08-25-2007, 08:50 PM   #3
tuxhats
Member
 
Registered: Dec 2005
Location: Austin, Texas area
Distribution: I have multiple Distos available, but I mostly use Ubuntu.
Posts: 47

Original Poster
Rep: Reputation: 16
Lightbulb How do I get a local(client) reboot (init 6) when a ssh connection is closed?

Thank you for the reply! It is late here and I am digesting your thoughts. As to your:

"Can't imagine why you would want to make it reboot though. If you don't script exceptions or a choice then reboot will happen on *every* ssh session exit, even where it failed to connect to a system due to whatever reasons."

EXACTLY! It keeps my students from highlighting their work, "right clicking", exiting their ssh session, logging onto a friends home directory through a ssh session, vi a file, PASTE.......... copy work from one to another.

NOTE: I teach programming in public school. "Our" environment is use of my this, my Knoppix LiveCD rewrite. They ssh onto a Linux server and work there ....... Got to stay ahead on these students!!!

Last edited by tuxhats; 08-25-2007 at 08:52 PM.
 
Old 08-26-2007, 05:36 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Isn't that a bit crude? Not to be idealistic about this, but if you expect or are faced with a major outbreak of plagiarism then wouldn't your efforts be better directed looking into *why* it's ocurring in the first place? I mean if you know they're good students but facing time constraints then maybe that's something to adjust? Else if they just don't give a rodent's ass wouldn't it be easier to look for common phrasing and such and allow for way more severe punishment for offenders?
 
Old 08-28-2007, 05:08 PM   #5
RobRistroph
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
Some Suggestions

Firstly, if you edit /etc/inittab to remove the extra "getty" lines, you can prevent the students from switching to another terminal.

To automatically have them ssh to the central server on login, and have it reboot when that ssh connection closes, try appending this to the existing /home/knoppix/.bash_profile :

echo "Your Server Login Name: "

read studentusername

echo "What Server IP Address: "

read remoteserver

ssh -l $studentusername $remoteserver

echo "You are done"

sudo shutdown -r now

There are also some tricks you can play by replacing the shell specified in /etc/password with a "wrapper" script. A good example is the cvsssh.pl script used for that purpose in gforge, you can find it on the web.

That should be enough to make it require more than a spur-of-the-moment impulse to cheat . . . then you can focus on teaching your course material instead of teaching what their parents should have taught them at home

--Rob
 
  


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 Connection Closed only when RSA Keys are present Sburk Linux - Software 3 06-07-2007 02:09 PM
SSH connection closed after username matcal Linux - Security 4 10-24-2005 11:04 AM
Can't reboot via ssh, but can from local terminal xymian Linux - Networking 2 09-05-2005 10:04 AM
ssh connection closed by server m_yates Linux - Security 3 08-10-2005 03:12 PM
rsync thru SSH --- connection unexpectedly closed shawn_t Linux - Networking 4 02-25-2005 02:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:02 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