<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18699" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2011-11-05T06:58:09-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18699</id>

		<entry>
		<author><name><![CDATA[ultralord]]></name></author>
		<updated>2011-11-05T06:58:09-04:00</updated>

		<published>2011-11-05T06:58:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98123#p98123</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98123#p98123"/>
		<title type="html"><![CDATA[connect to remote machine with ssh]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98123#p98123"><![CDATA[
thanks i will take a look yes <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":-)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8360">ultralord</a> — Sat Nov 05, 2011 6:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-11-04T12:58:32-04:00</updated>

		<published>2011-11-04T12:58:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98117#p98117</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98117#p98117"/>
		<title type="html"><![CDATA[connect to remote machine with ssh]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98117#p98117"><![CDATA[
Lets see...<br>First off, tcl has no native support for ssh. Thus you'll either have to rely on an external binary, or load some extension to provide ssh functionality.<br><br>Which brings us to the next post. This script is written for expect, not tcl. At a minimum you'd need to make sure this is installed along with the appropriate tcl packages, and you'll have to load the expect package in your script:<div class="codebox"><p>Code: </p><pre><code>package require expect</code></pre></div>Next, all expect does, is spawn an external process, and implement a framework for challenge/response operation with this process. However, this interaction is blocking, and will thus prevent your eggdrop from performing any other tasks while the ssh-session is being managed.<br><br>For sending a single command through a ssh-session, you could achieve this alot simpler using the ssh-client's commandline options along with rsa or dsa keypairs.<div class="codebox"><p>Code: </p><pre><code>...[exec /usr/bin/ssh -i .ssh/id_eggdrop.rsa user@example.com remotecommand with options &amp;]...</code></pre></div>Details for setting up rsa and/or dsa keypairs, along with setting up automated remote logins over ssh is well covered in the ssh documentations, so I'm not going into depths on that here.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Nov 04, 2011 12:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ultralord]]></name></author>
		<updated>2011-11-04T09:35:53-04:00</updated>

		<published>2011-11-04T09:35:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98115#p98115</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98115#p98115"/>
		<title type="html"><![CDATA[connect to remote machine with ssh]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98115#p98115"><![CDATA[
i found this:<br><div class="codebox"><p>Code: </p><pre><code>#!/usr/bin/expect################################################################# What we are trying to create here is a method of# running SSH all at once. AKA - the user enters# user/pass/host/command all at once, and this# script takes care of the rest of the hard stuff.#===============================================================set USERNAME [lindex $argv 0]set PASSWORD [lindex $argv 1]set SERVER [lindex $argv 2]set COMMAND [lindex $argv 3]# Since we are going to need something to "expect"# we may as well put a temp global variable to the# task.set NEW_PROMPT "."set CHECK_FOR "EXPECT_ME"################################################################# What we want to do here is:#  1 - Make sure we are getting *some* interaction#  2 - Set the remote terminal (on some types of#      servers) prompt to something pre-specified#  3 - Expect that we can now see the prompt as the#      first thing on a line when we hit &lt;ENTER&gt;#  4 - Send a newline, so that the next thing we#      can do is start with another expect#  5 - Return 0 if it didnt fail, or 1 if it failed#===============================================================proc setPrompt_fail {} {   global CHECK_FOR   expect {       -re "." {           send "PS1=$CHECK_FOR\n"           expect {               -re "^$CHECK_FOR" {                   set NEW_PROMPT $CHECK_FOR                   send "\n"                   return 0               }           }           return 1       }   }   return 1}################################################################# What we want to do here is:#  1 - Get the password argument#  2 - Determine what type of SSH connection is#      being made: 1st requires authentication#      and password, 2nd requires only password,#      3rd requires nothing (passwordless SSH)#  3 - For each type, send and expect, up to the#      point of verified login#  4 - Attempt to set the prompt of the remote#      machine#  5 - Return 1 if connect fails, 0 if success#===============================================================proc connect_fail {} {   global PASSWORD   expect {       "(yes/no)" {           send "yes\n"           expect {               "assword:" {                   send "$PASSWORD\n"                   expect {                       -re "." {                           send "\n"                           if {[setPrompt_fail]} {                               puts "I couldnt set the remote prompt\n"                           } else {                               return 0                           }                       }                   }               }           }       }       "assword:" {           send "$PASSWORD\n"           expect {               -re "." {                   if {[setPrompt_fail]} {                       puts "I couldnt set the remote prompt\n"                   } else {                       return 0                   }               }           }       }       -re "." {           if {[setPrompt_fail]} {               puts "I couldnt set the remote prompt\n"           } else {               return 0           }       }   }   return 1}################################################################# Main Functionality:#  1 - Turn off logging#  2 - Spawn SSH connection (using argvs)#  3 - Do the hard stuff (passwords &amp; stuff)#  4 - Expect the newly-set prompt#  5 - Run the argv-quoted command#  6 - Log ONLY the output from the command#      not all the prompts and such#===============================================================log_user 0spawn ssh $USERNAME@$SERVERif {[connect_fail]} {   puts "Well that was a miserable failure...\n"} else {   expect {       -re "^$NEW_PROMPT" {           send "$COMMAND\n"           log_user 1       }   }   send "exit\n"   expect "logout"   expect eof}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8360">ultralord</a> — Fri Nov 04, 2011 9:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ultralord]]></name></author>
		<updated>2011-11-04T06:16:23-04:00</updated>

		<published>2011-11-04T06:16:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98111#p98111</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98111#p98111"/>
		<title type="html"><![CDATA[connect to remote machine with ssh]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98111#p98111"><![CDATA[
Hello with tcl scripting can i connect and execute command to remote machine with ssh?? can someone tell me? and how?<br><br><br>thanks..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8360">ultralord</a> — Fri Nov 04, 2011 6:16 am</p><hr />
]]></content>
	</entry>
	</feed>
