Jump to content

Search the Community

Showing results for tags 'ssh'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Custom Function Library

Community Forums

  • Community Resources
    • Community Articles, Tips, & Techniques
    • FileMaker Marketplace Discussions
  • FileMaker Security Management
    • Security Concepts
    • Intellectual Property
  • FileMaker Server Administration
    • FileMaker Server 16
    • FileMaker Custom SSL Certificates
    • External Server Authentication
  • FileMaker Go & Mobile Strategies
    • FileMaker Go for iPhone & iPad
    • iBeacon Support
    • FileMaker IOS App SDK
  • FileMaker and the Internet
    • FileMaker REST API
    • FileMaker Cloud
    • FileMaker WebDirect
    • Custom Web Publishing
    • Other Internet Technologies
  • FileMaker Interface Features
    • Cards & Window Management
    • Interface Design Discussions
    • Layouts
    • Themes and Styles
    • Button, Popovers, Button Bars, SVG Icons
    • Tab and Slide Control Panels
    • Portals
    • Web Viewer
    • Conditional Formatting
    • Custom Menus
    • Value Lists
    • Tool Tips
  • FileMaker Schema & Logical Functions
    • Managing Scripts
    • Calculation Engine (Define Fields)
    • Custom Functions Discussions
    • FileMaker Query Language or FQL
    • Relationships
    • Charting
    • Remote Container Fields
    • Finding & Searching
    • Importing & Exporting
    • External Data Sources
    • Advanced & Developer Features
    • Reports, Printing & Publication
  • Brain Food
    • The Left Brain
    • Upgrading & Migration
    • Data Analysis
    • Development Standards
    • The Separation Model
    • Relational Database Theory
    • Damaged / Corrupt File Problems
    • OS Level Database Automation
    • Hardware & Networking
    • Bar Codes (Printer, Scanners, Software)
    • Accounting Solutions
  • FileMaker Discussions
    • FileMaker Pro 16
    • FileMaker Pro 15
    • Legacy FileMaker Platform Discussions
  • Geist Interactive Product Support Forums
    • Visit Geist Interactive
    • Visit Modular FileMaker
    • FMPerception
    • Generator
    • fmQBO
  • 360 Works Official Product Support Forums
    • 360 Works General Support
    • MirrorSync by 360Works
    • SuperContainer by 360 Works
    • ScriptMaster by 360 Works
    • FTPeek by 360 Works
    • 360Works Email Plugin
    • DocuBin by 360 Works
    • Zulu – FileMaker, iCal & Google Calendar.
  • FM Forums Affiliate Sponsors
    • SyncServer Pro by LinearBlue
    • Open Source Frameworks
    • Monkey Bread Software (MBS Plugin)
    • FileMaker Plug-Ins
    • ISO FileMaker Magazine
    • User Group Central - Sponsored by FMPug.com
  • FM Starting Point - By Richard Carlton Consulting
    • Visit FM Starting Point
    • FM Starting Point - General Discussions
  • FileMaker Classifieds
    • FileMaker Product & Service Announcements
    • Professional FileMaker Training
    • Services for Hire
    • Services Wanted
    • Solutions Wanted
    • Tools Of The Trade
  • The Water Cooler
    • Member Lounge
    • Wants & Wishes
  • FM Forums Operations
    • FM Forums Feedback & Site News
    • Site Instructions
  • FileMaker Platform

Blogs

  • Captain's Blog
  • FileMaker Weetbicks
  • FileMaker Security Blog
  • The FileMaker Rift
  • HOnza's Bits @ FMForums
  • SeedCode
  • CampSoftware, Hal Gumbert
  • FileMaker Hacks
  • Skeleton Key's Blog
  • Wing Forward Solutions
  • 360Works Articles and Tutorials
  • GoBillit
  • Filemaker - an amateur's view
  • Linear Blue
  • Surya Kanta Mekap's Blog
  • eXcelisys' Blog
  • Manjit Behera
  • Blue Feather's Blog
  • RCC's FileMaker News and Bits
  • Thorsen Consulting
  • DB Services Blog
  • FileMaker Magazine
  • Eye on FileMaker
  • Dev Talk
  • The Philosophy of FileMaker
  • Button Bar Icon - Text Alignment Issue

Categories

  • Samples
  • Solutions
  • White Papers
  • Plug-Ins
  • FMGo

Found 2 results

  1. Executing SSH commands

    Here's some code I put together using the Ganymed SSH java library and examples to execute SSH commands using ScriptMaster. Its easier than doing SSH calls from RunShellScript. I'm sure there's improvements to be made. Cheers, JP // SSHCommand ( hostname ; privateKey ; username ; command ) // Uses Commons-Io-2.4.jar // Uses Commons-Lang-2.6.jar // Uses Ganymed-Ssh2-261.jar import java.io.IOException; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import ch.ethz.ssh2.Connection; import ch.ethz.ssh2.Session; import ch.ethz.ssh2.StreamGobbler; final String stdout = new String(); final String stderr = new String(); try { // Convert private key to character array char[] privateKeyArray = privateKey.toCharArray(); // Create and open connection Connection theConnection = new Connection(hostname); theConnection.connect(); // Authenticate with public (private really) key boolean isSuccess = theConnection.authenticateWithPublicKey(username, privateKeyArray, null); if (isSuccess == false) throw new RuntimeException( "ERROR: Authentication error" ); // Open seession and execute command final Session theSession = theConnection.openSession(); theSession.execCommand(command); // Get stdout stream and convert to string final InputStream stdoutStream = new StreamGobbler(theSession.getStdout()); final InputStream stderrStream = new StreamGobbler(theSession.getStderr()); stdout = IOUtils.toString(stdoutStream, "UTF-8"); stderr = IOUtils.toString(stderrStream, "UTF-8"); // Close streams stdoutStream.close(); stderrStream.close(); // Close the session and connection theSession.close(); theConnection.close(); if (StringUtils.isNotEmpty(stderr)) throw new RuntimeException( stderr ); // Return the string return stdout; } catch (IOException e) { throw new RuntimeException( e ); }
  2. So here's code for sending or receiving a file through SCP (SSH secure copy) with ScriptMaster. Requires the Orion SSH-2 java library from http://sourceforge.net/apps/mediawiki/orion-ssh2/index.php . They can be easily adapted to use put/get methods that will get or put multiple files at once. Comments and suggestions always welcome. SCPGet ( hostname ; privateKey ; username ; localTargetDirectory ; remoteFile ) import java.io.IOException; import com.trilead.ssh2.Connection; import com.trilead.ssh2.SCPClient; try { // Convert private key to character array char[] privateKeyArray = privateKey.toCharArray(); // Create and open connection Connection theConnection = new Connection(hostname); theConnection.connect(); // Authenticate with public (private really) key boolean isSuccess = theConnection.authenticateWithPublicKey(username, privateKeyArray, null); if (isSuccess == false) throw new RuntimeException( "ERROR: Authentication error" ); // Create SCP client and get remote file to local target directory SCPClient theClient = new SCPClient (theConnection); theClient.get(remoteFile, localTargetDirectory); // Close the connection theConnection.close(); return; } catch (IOException e) { throw new RuntimeException( e ); } SCPPut ( privateKey ; hostname ; username ; remoteTargetDirectory ; localFile ) import java.io.IOException; import com.trilead.ssh2.Connection; import com.trilead.ssh2.SCPClient; try { // Convert private key to character array char[] privateKeyArray = privateKey.toCharArray(); // Create and open connection Connection theConnection = new Connection(hostname); theConnection.connect(); // Authenticate with public (private really) key boolean isSuccess = theConnection.authenticateWithPublicKey(username, privateKeyArray, null); if (isSuccess == false) throw new RuntimeException( "ERROR: Authentication error" ); // Create SCP client and put local file to remote target directory with mode 600 SCPClient theClient = new SCPClient (theConnection); theClient.put(localFile, remoteTargetDirectory); // Close the connection theConnection.close(); return; } catch (IOException e) { throw new RuntimeException( e ); } Code on, JP
×

Important Information

By using this site, you agree to our Terms of Use.