本文整理汇总了Java中org.apache.sshd.SshClient.setUpDefaultClient方法的典型用法代码示例。如果您正苦于以下问题:Java SshClient.setUpDefaultClient方法的具体用法?Java SshClient.setUpDefaultClient怎么用?Java SshClient.setUpDefaultClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.sshd.SshClient
的用法示例。
在下文中一共展示了SshClient.setUpDefaultClient方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KarafSshShellConnection
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
/**
* Creates a remote shell connection to a Karaf instance using the SSH
* protocol
*
* @param connectionUrl
* the coordinates used to establish the connection
* @param credentials
* the username and password used to authenticate when connection
* @param inputStream
* the {@link InputStream} used to interact with the remote
* system
* @param outputStream
* the {@link OutputStream} used to receive data from
* {@code stdout} of the remote system
* @param errorStream
* the {@link OutputStream} used to receive data from
* {@code stderr} of the remote system
*/
public KarafSshShellConnection(
final KarafSshConnectionUrl connectionUrl,
final Credentials credentials,
final InputStream inputStream,
final OutputStream outputStream,
final OutputStream errorStream)
{
this.connectionUrl = connectionUrl;
this.credentials = credentials;
this.inputStream = inputStream;
this.outputStream = outputStream;
this.errorStream = errorStream;
this.exception = null;
this.sshClient = SshClient.setUpDefaultClient();
}
示例2: setUp
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
@SuppressWarnings("serial")
@Before
public void setUp() throws Exception {
app = new Application() {
@Override
public void init() {}
};
mainWindow = new Window();
app.setMainWindow(mainWindow);
SSHWindow sshWindow = new SSHWindow(null, 200, 200);
app.getMainWindow().addWindow(sshWindow);
SshClient client = SshClient.setUpDefaultClient();
client.start();
ClientSession session = null;
try {
session = client.connect(testHost, testPort).await().getSession();
} catch (Exception e) {
fail("Could not connect to host");
}
sshTerm = new SSHTerminal(sshWindow, session, 200, 200);
sshWindow.addComponent(sshTerm);
}
示例3: setup
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
@SuppressWarnings("serial")
@Before
public void setup () {
app = new Application() {
@Override
public void init() {}
};
sshWindow = new SSHWindow(null, 200, 200);
client = SshClient.setUpDefaultClient();
client.start();
try {
session = client.connect(testHost, testPort).await().getSession();
} catch (Exception e) {
fail("Could not connect to host");
}
sshWindow2 = new SSHWindow(session, 200, 200);
mainWindow = new Window();
app.setMainWindow(mainWindow);
app.getMainWindow().addWindow(sshWindow);
app.getMainWindow().addWindow(sshWindow2);
}
示例4: call
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
@Test(timeout = 10000L)
public void call() throws Exception {
final SshClient client = SshClient.setUpDefaultClient();
client.start();
try {
final ClientSession session = client.connect("localhost", 4222).await().getSession();
session.authPassword("jonathan", "secret");
final ClientChannel channel = session.createChannel("shell");
ByteArrayOutputStream sent = new ByteArrayOutputStream();
PipedOutputStream pipedIn = new TeePipedOutputStream(sent);
channel.setIn(new PipedInputStream(pipedIn));
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
channel.setOut(out);
channel.setErr(err);
channel.open();
pipedIn.write("properties\r\n".getBytes());
pipedIn.flush();
pipedIn.write("exit\r\n".getBytes());
pipedIn.flush();
channel.waitFor(ClientChannel.CLOSED, 0);
channel.close(false);
client.stop();
assertTrue(new String(sent.toByteArray()).contains("properties\r\nexit\r\n"));
assertTrue(new String(out.toByteArray()).contains("ServerService(id=ssh)"));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
示例5: doStart
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
client = SshClient.setUpDefaultClient();
client.start();
super.doStart();
}
示例6: setup
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
@PostConstruct
protected void setup(){
sshClient = SshClient.setUpDefaultClient();
sshClient.start();
}
示例7: SshConnectionFactory
import org.apache.sshd.SshClient; //导入方法依赖的package包/类
public SshConnectionFactory() {
client = SshClient.setUpDefaultClient();
}