author | wenzelm |
Tue, 11 Oct 2016 09:32:56 +0200 | |
changeset 64137 | e9b3d9c1bc5a |
parent 64136 | 7c5191489457 |
child 64141 | 79cd4be708fb |
permissions | -rw-r--r-- |
64123 | 1 |
/* Title: Pure/General/ssh.scala |
2 |
Author: Makarius |
|
3 |
||
64124 | 4 |
SSH client based on JSch (see also http://www.jcraft.com/jsch/examples). |
64123 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
10 |
import java.io.{InputStream, OutputStream, ByteArrayOutputStream} |
64131 | 11 |
|
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
12 |
import scala.collection.{mutable, JavaConversions} |
64131 | 13 |
|
64123 | 14 |
import com.jcraft.jsch.{JSch, Logger => JSch_Logger, Session => JSch_Session, |
64132 | 15 |
OpenSSHConfig, UserInfo, Channel => JSch_Channel, ChannelExec, ChannelSftp, SftpATTRS} |
64123 | 16 |
|
17 |
||
18 |
object SSH |
|
19 |
{ |
|
20 |
/* init */ |
|
21 |
||
64130 | 22 |
def init(options: Options): SSH = |
64123 | 23 |
{ |
64130 | 24 |
val config_dir = Path.explode(options.string("ssh_config_dir")) |
64123 | 25 |
if (!config_dir.is_dir) error("Bad ssh config directory: " + config_dir) |
26 |
||
27 |
val jsch = new JSch |
|
28 |
||
64130 | 29 |
val config_file = Path.explode(options.string("ssh_config_file")) |
64123 | 30 |
if (config_file.is_file) |
31 |
jsch.setConfigRepository(OpenSSHConfig.parseFile(File.platform_path(config_file))) |
|
32 |
||
33 |
val known_hosts = config_dir + Path.explode("known_hosts") |
|
34 |
if (!known_hosts.is_file) known_hosts.file.createNewFile |
|
35 |
jsch.setKnownHosts(File.platform_path(known_hosts)) |
|
36 |
||
64130 | 37 |
val identity_files = |
38 |
Library.space_explode(':', options.string("ssh_identity_files")).map(Path.explode(_)) |
|
64123 | 39 |
for (identity_file <- identity_files if identity_file.is_file) |
40 |
jsch.addIdentity(File.platform_path(identity_file)) |
|
41 |
||
64130 | 42 |
new SSH(options, jsch) |
64123 | 43 |
} |
44 |
||
64130 | 45 |
def connect_timeout(options: Options): Int = |
46 |
options.seconds("ssh_connect_timeout").ms.toInt |
|
47 |
||
64123 | 48 |
|
49 |
/* logging */ |
|
50 |
||
51 |
def logging(verbose: Boolean = true, debug: Boolean = false) |
|
52 |
{ |
|
53 |
JSch.setLogger(if (verbose) new Logger(debug) else null) |
|
54 |
} |
|
55 |
||
56 |
private class Logger(debug: Boolean) extends JSch_Logger |
|
57 |
{ |
|
58 |
def isEnabled(level: Int): Boolean = level != JSch_Logger.DEBUG || debug |
|
59 |
||
60 |
def log(level: Int, msg: String) |
|
61 |
{ |
|
62 |
level match { |
|
63 |
case JSch_Logger.ERROR | JSch_Logger.FATAL => Output.error_message(msg) |
|
64 |
case JSch_Logger.WARN => Output.warning(msg) |
|
65 |
case _ => Output.writeln(msg) |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
||
64128 | 71 |
/* user info */ |
72 |
||
73 |
object No_User_Info extends UserInfo |
|
74 |
{ |
|
75 |
def getPassphrase: String = null |
|
76 |
def getPassword: String = null |
|
77 |
def promptPassword(msg: String): Boolean = false |
|
78 |
def promptPassphrase(msg: String): Boolean = false |
|
79 |
def promptYesNo(msg: String): Boolean = false |
|
80 |
def showMessage(msg: String): Unit = Output.writeln(msg) |
|
81 |
} |
|
82 |
||
83 |
||
64132 | 84 |
/* channel */ |
64129 | 85 |
|
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
86 |
class Channel[C <: JSch_Channel] private[SSH]( |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
87 |
val session: Session, val kind: String, val options: Options, val channel: C) |
64129 | 88 |
{ |
64130 | 89 |
override def toString: String = kind + " " + session.toString |
64129 | 90 |
|
91 |
def close { channel.disconnect } |
|
92 |
} |
|
93 |
||
64132 | 94 |
|
95 |
/* exec channel */ |
|
96 |
||
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
97 |
private val exec_wait_delay = Time.seconds(0.3) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
98 |
|
64131 | 99 |
class Exec private[SSH]( |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
100 |
session: Session, kind: String, options: Options, channel: ChannelExec) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
101 |
extends Channel[ChannelExec](session, kind, options, channel) |
64131 | 102 |
{ |
103 |
def kill(signal: String) { channel.sendSignal(signal) } |
|
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
104 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
105 |
val exit_status: Future[Int] = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
106 |
Future.thread("ssh_wait") { |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
107 |
while (!channel.isClosed) Thread.sleep(exec_wait_delay.ms) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
108 |
channel.getExitStatus |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
109 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
110 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
111 |
val stdin: OutputStream = channel.getOutputStream |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
112 |
val stdout: InputStream = channel.getInputStream |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
113 |
val stderr: InputStream = channel.getErrStream |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
114 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
115 |
// after preparing streams |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
116 |
channel.connect(connect_timeout(options)) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
117 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
118 |
def result( |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
119 |
progress_stdout: String => Unit = (_: String) => (), |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
120 |
progress_stderr: String => Unit = (_: String) => (), |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
121 |
strict: Boolean = true): Process_Result = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
122 |
{ |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
123 |
stdin.close |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
124 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
125 |
def read_lines(stream: InputStream, progress: String => Unit): List[String] = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
126 |
{ |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
127 |
val result = new mutable.ListBuffer[String] |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
128 |
val line_buffer = new ByteArrayOutputStream(100) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
129 |
def line_flush() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
130 |
{ |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
131 |
val line = line_buffer.toString(UTF8.charset_name) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
132 |
progress(line) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
133 |
result += line |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
134 |
line_buffer.reset |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
135 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
136 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
137 |
var c = 0 |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
138 |
var finished = false |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
139 |
while (!finished) { |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
140 |
while ({ c = stream.read; c != -1 && c != 10 }) line_buffer.write(c) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
141 |
if (c == 10) line_flush() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
142 |
else if (channel.isClosed) { |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
143 |
if (line_buffer.size > 0) line_flush() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
144 |
finished = true |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
145 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
146 |
else Thread.sleep(exec_wait_delay.ms) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
147 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
148 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
149 |
result.toList |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
150 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
151 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
152 |
val out_lines = Future.thread("ssh_stdout") { read_lines(stdout, progress_stdout) } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
153 |
val err_lines = Future.thread("ssh_stderr") { read_lines(stderr, progress_stderr) } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
154 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
155 |
def terminate() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
156 |
{ |
64136 | 157 |
close |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
158 |
out_lines.join |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
159 |
err_lines.join |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
160 |
exit_status.join |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
161 |
} |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
162 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
163 |
val rc = |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
164 |
try { exit_status.join } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
165 |
catch { case Exn.Interrupt() => terminate(); Exn.Interrupt.return_code } |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
166 |
|
64136 | 167 |
close |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
168 |
if (strict && rc == Exn.Interrupt.return_code) throw Exn.Interrupt() |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
169 |
|
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
170 |
Process_Result(rc, out_lines.join, err_lines.join) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
171 |
} |
64131 | 172 |
} |
173 |
||
174 |
||
64132 | 175 |
/* Sftp channel */ |
176 |
||
177 |
type Attrs = SftpATTRS |
|
178 |
||
179 |
sealed case class Dir_Entry(name: String, attrs: Attrs) |
|
180 |
{ |
|
181 |
def is_file: Boolean = attrs.isReg |
|
182 |
def is_dir: Boolean = attrs.isDir |
|
183 |
} |
|
184 |
||
64131 | 185 |
class Sftp private[SSH]( |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
186 |
session: Session, kind: String, options: Options, channel: ChannelSftp) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
187 |
extends Channel[ChannelSftp](session, kind, options, channel) |
64131 | 188 |
{ |
64134
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
189 |
channel.connect(connect_timeout(options)) |
57581e4026fe
proper support for exec channel (see also bash.scala);
wenzelm
parents:
64133
diff
changeset
|
190 |
|
64131 | 191 |
def home: String = channel.getHome() |
192 |
||
193 |
def chmod(permissions: Int, remote_path: String) { channel.chmod(permissions, remote_path) } |
|
194 |
def mv(remote_path1: String, remote_path2: String): Unit = |
|
195 |
channel.rename(remote_path1, remote_path2) |
|
196 |
def rm(remote_path: String) { channel.rm(remote_path) } |
|
197 |
def mkdir(remote_path: String) { channel.mkdir(remote_path) } |
|
198 |
def rmdir(remote_path: String) { channel.rmdir(remote_path) } |
|
199 |
||
64132 | 200 |
def stat(remote_path: String): Dir_Entry = |
201 |
Dir_Entry(remote_path, channel.stat(remote_path)) |
|
202 |
||
203 |
def read_dir(remote_path: String): List[Dir_Entry] = |
|
204 |
{ |
|
205 |
val dir = channel.ls(remote_path) |
|
206 |
(for { |
|
207 |
i <- (0 until dir.size).iterator |
|
208 |
a = dir.get(i).asInstanceOf[AnyRef] |
|
209 |
name = Untyped.get[String](a, "filename") |
|
210 |
attrs = Untyped.get[Attrs](a, "attrs") |
|
211 |
if name != "." && name != ".." |
|
212 |
} yield Dir_Entry(name, attrs)).toList |
|
213 |
} |
|
214 |
||
215 |
def find_files(remote_path: String, pred: Dir_Entry => Boolean = _ => true): List[Dir_Entry] = |
|
216 |
{ |
|
217 |
def find(dir: String): List[Dir_Entry] = |
|
218 |
read_dir(dir).flatMap(entry => |
|
219 |
{ |
|
220 |
val file = dir + "/" + entry.name |
|
64133 | 221 |
if (entry.is_dir) find(file) |
222 |
else if (pred(entry)) List(entry.copy(name = file)) |
|
223 |
else Nil |
|
64132 | 224 |
}) |
225 |
find(remote_path) |
|
226 |
} |
|
227 |
||
64131 | 228 |
def open_input(remote_path: String): InputStream = channel.get(remote_path) |
229 |
def open_output(remote_path: String): OutputStream = channel.put(remote_path) |
|
230 |
||
231 |
def read_file(remote_path: String, local_path: Path): Unit = |
|
232 |
channel.get(remote_path, File.platform_path(local_path)) |
|
233 |
def read_bytes(remote_path: String): Bytes = |
|
234 |
using(open_input(remote_path))(Bytes.read_stream(_)) |
|
235 |
def read(remote_path: String): String = |
|
236 |
using(open_input(remote_path))(File.read_stream(_)) |
|
237 |
||
238 |
def write_file(remote_path: String, local_path: Path): Unit = |
|
239 |
channel.put(File.platform_path(local_path), remote_path) |
|
240 |
def write_bytes(remote_path: String, bytes: Bytes): Unit = |
|
241 |
using(open_output(remote_path))(bytes.write_stream(_)) |
|
242 |
def write(remote_path: String, text: String): Unit = |
|
243 |
using(open_output(remote_path))(stream => Bytes(text).write_stream(stream)) |
|
244 |
} |
|
245 |
||
64129 | 246 |
|
64123 | 247 |
/* session */ |
248 |
||
64130 | 249 |
class Session private[SSH](val session_options: Options, val session: JSch_Session) |
64123 | 250 |
{ |
251 |
override def toString: String = |
|
252 |
(if (session.getUserName == null) "" else session.getUserName + "@") + |
|
253 |
(if (session.getHost == null) "" else session.getHost) + |
|
64126 | 254 |
(if (session.getPort == 22) "" else ":" + session.getPort) + |
255 |
(if (session.isConnected) "" else " (disconnected)") |
|
64123 | 256 |
|
64126 | 257 |
def close { session.disconnect } |
64123 | 258 |
|
64135
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
259 |
def execute(command: String, |
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
260 |
options: Options = session_options, |
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
261 |
progress_stdout: String => Unit = (_: String) => (), |
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
262 |
progress_stderr: String => Unit = (_: String) => (), |
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
263 |
strict: Boolean = true): Process_Result = |
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
264 |
exec(command, options).result(progress_stdout, progress_stderr, strict) |
865dda40e1cc
provide execute operation, similar to Isabelle_System.bash;
wenzelm
parents:
64134
diff
changeset
|
265 |
|
64131 | 266 |
def exec(command: String, options: Options = session_options): Exec = |
64129 | 267 |
{ |
64130 | 268 |
val kind = "exec" |
269 |
val channel = session.openChannel(kind).asInstanceOf[ChannelExec] |
|
64129 | 270 |
channel.setCommand(command) |
64131 | 271 |
new Exec(this, kind, options, channel) |
64129 | 272 |
} |
64123 | 273 |
|
64131 | 274 |
def sftp(options: Options = session_options): Sftp = |
64130 | 275 |
{ |
276 |
val kind = "sftp" |
|
277 |
val channel = session.openChannel(kind).asInstanceOf[ChannelSftp] |
|
64131 | 278 |
new Sftp(this, kind, options, channel) |
64130 | 279 |
} |
64137 | 280 |
|
281 |
||
282 |
/* tmp dirs */ |
|
283 |
||
284 |
def rm_tree(remote_dir: String): Unit = |
|
285 |
execute("rm -r -f " + File.bash_string(remote_dir)).check |
|
286 |
||
287 |
def tmp_dir(): String = |
|
288 |
execute("mktemp -d -t tmp.XXXXXXXXXX").check.out |
|
289 |
||
290 |
def with_tmp_dir[A](body: String => A): A = |
|
291 |
{ |
|
292 |
val remote_dir = tmp_dir() |
|
293 |
try { body(remote_dir) } finally { rm_tree(remote_dir) } |
|
294 |
} |
|
64123 | 295 |
} |
296 |
} |
|
297 |
||
64130 | 298 |
class SSH private(val options: Options, val jsch: JSch) |
64123 | 299 |
{ |
64130 | 300 |
def open_session(host: String, port: Int = 22, user: String = null): SSH.Session = |
64123 | 301 |
{ |
302 |
val session = jsch.getSession(user, host, port) |
|
64125
a034dac5ca3c
clarified (hardwired!) default (see also jEdit/FTP);
wenzelm
parents:
64124
diff
changeset
|
303 |
|
a034dac5ca3c
clarified (hardwired!) default (see also jEdit/FTP);
wenzelm
parents:
64124
diff
changeset
|
304 |
session.setUserInfo(SSH.No_User_Info) |
a034dac5ca3c
clarified (hardwired!) default (see also jEdit/FTP);
wenzelm
parents:
64124
diff
changeset
|
305 |
session.setConfig("MaxAuthTries", "3") |
a034dac5ca3c
clarified (hardwired!) default (see also jEdit/FTP);
wenzelm
parents:
64124
diff
changeset
|
306 |
|
64130 | 307 |
if (options.bool("ssh_compression")) { |
64123 | 308 |
session.setConfig("compression.s2c", "zlib@openssh.com,zlib,none") |
309 |
session.setConfig("compression.c2s", "zlib@openssh.com,zlib,none") |
|
310 |
session.setConfig("compression_level", "9") |
|
311 |
} |
|
64125
a034dac5ca3c
clarified (hardwired!) default (see also jEdit/FTP);
wenzelm
parents:
64124
diff
changeset
|
312 |
|
64130 | 313 |
session.connect(SSH.connect_timeout(options)) |
314 |
new SSH.Session(options, session) |
|
64123 | 315 |
} |
316 |
} |