[Swift-commit] r8175 - SwiftTutorials/ATPESC_2014-08-14/swift-k/part08

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Thu Aug 14 10:16:26 CDT 2014


Author: wilde
Date: 2014-08-14 10:16:26 -0500 (Thu, 14 Aug 2014)
New Revision: 8175

Added:
   SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh
   SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh
Log:
Commands for remote exec.

Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh	2014-08-14 15:16:26 UTC (rev 8175)
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+SSHSOCKET=~/.ssh/$USER at cetus.alcf.anl.gov
+
+ssh -o ControlPath=$SSHSOCKET $USER at cetus.alcf.anl.gov $*
+
+# scp -o ControlPath=$SSHSOCKET myUsername at targetServerName:remoteFile.txt ./
\ No newline at end of file


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh	2014-08-14 15:16:26 UTC (rev 8175)
@@ -0,0 +1,24 @@
+#! /bin/sh
+
+SSHSOCKET=~/.ssh/$USER at cetus.alcf.anl.gov
+ssh -M  -N -o ControlPath=$SSHSOCKET $USER at cetus.alcf.anl.gov
+
+# ssh -M -f -N -o ControlPath=$SSHSOCKET $USER at cetus.alcf.anl.gov
+
+exit
+
+The options have the following meaning:
+
+-M instructs SSH to become the master, i.e. to create a master socket that will be used by the slave connections
+-f makes SSH to go into the background after the authentication
+-N tells SSH not to execute any command or to expect an input from the user; that’s good because we want it only to manage and keep open the master connection and nothing else
+-o ControlPath=$SSHSOCKET – this defines the name to be used for the socket that represents the master connection; the slaves will use the same value to connect via it
+Thanks to -N and -f the SSH master connection will get out of the way but will stay open and such usable by subsequent ssh/scp invocations. This is exactly what we need in a shell script. If you just do something manually than you can leave out -N and -f and use directly this connection for whatever you need while you can also open a slave connection in another terminal window. Just don’t forget that once the master connection exits slaves won’t work.
+
+2. Open and close other connections without re-authenticating as you like
+
+Now you can do as many ssh/scp operations as you like and you won’t be prompted for a password. You only always have to provide the command with the same ControlPath, which we ensure by having stored it into the variable SSHSOCKET:
+
+ssh -o ControlPath=$SSHSOCKET myUsername at targetServerName "echo 'Hello from the remote server!'; ls"
+...
+scp -o ControlPath=$SSHSOCKET myUsername at targetServerName:remoteFile.txt ./
\ No newline at end of file


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh
___________________________________________________________________
Added: svn:executable
   + *




More information about the Swift-commit mailing list