src/Pure/General/ssh.scala
changeset 71780 21adf2ed442c
parent 71684 5036edb025b7
child 72338 54871a086193
equal deleted inserted replaced
71777:3875815f5967 71780:21adf2ed442c
    11 
    11 
    12 import scala.collection.mutable
    12 import scala.collection.mutable
    13 import scala.util.matching.Regex
    13 import scala.util.matching.Regex
    14 
    14 
    15 import com.jcraft.jsch.{JSch, Logger => JSch_Logger, Session => JSch_Session, SftpException,
    15 import com.jcraft.jsch.{JSch, Logger => JSch_Logger, Session => JSch_Session, SftpException,
    16   OpenSSHConfig, UserInfo, Channel => JSch_Channel, ChannelExec, ChannelSftp, SftpATTRS}
    16   OpenSSHConfig, UserInfo, Channel => JSch_Channel, ChannelExec, ChannelSftp, SftpATTRS,
       
    17   JSchException}
    17 
    18 
    18 
    19 
    19 object SSH
    20 object SSH
    20 {
    21 {
    21   /* target machine: user@host syntax */
    22   /* target machine: user@host syntax */
    76     if (!known_hosts.is_file) known_hosts.file.createNewFile
    77     if (!known_hosts.is_file) known_hosts.file.createNewFile
    77     jsch.setKnownHosts(File.platform_path(known_hosts))
    78     jsch.setKnownHosts(File.platform_path(known_hosts))
    78 
    79 
    79     val identity_files =
    80     val identity_files =
    80       space_explode(':', options.string("ssh_identity_files")).map(Path.explode)
    81       space_explode(':', options.string("ssh_identity_files")).map(Path.explode)
    81     for (identity_file <- identity_files if identity_file.is_file)
    82     for (identity_file <- identity_files if identity_file.is_file) {
    82       jsch.addIdentity(File.platform_path(identity_file))
    83       try { jsch.addIdentity(File.platform_path(identity_file)) }
       
    84       catch {
       
    85         case exn: JSchException =>
       
    86           error("Error in ssh identity file " + identity_file + ": " + exn.getMessage)
       
    87       }
       
    88     }
    83 
    89 
    84     new Context(options, jsch)
    90     new Context(options, jsch)
    85   }
    91   }
    86 
    92 
    87   def open_session(options: Options,
    93   def open_session(options: Options,