Javaプログラムを実装していますが、
- リモートサーバーに接続する必要がある
- 接続されたリモート サーバーは、ftp からファイルをダウンロードする必要があります
このコードには Apache MINA lib を使用しています
これがリモートサーバーに接続するコードです
public class filetrans
{
public static void main(String[] args) throws IOException, InterruptedException
{
SshClient client = null;
String login="user";
String password="password";
try
{
client = SshClient.setUpDefaultClient();
client.start();
ConnectFuture future = client.connect("myhost",myport);
future.await();
ClientSession session = (ClientSession) future.getSession();
boolean auth = session.authPassword(login, password).await().isSuccess();
if (auth)
{
System.out.println("Authenticated....");
ClientChannel channel = session.createChannel("shell");
channel.setIn(new NoCloseInputStream(System.in));
channel.setOut(new NoCloseOutputStream(System.out));
channel.setErr(new NoCloseOutputStream(System.err));
channel.open();
channel.waitFor(ClientChannel.CLOSED, 5000);
channel.close(true);
}
else
{
System.out.println("Authentication failed....");
}
}
catch (Throwable t)
{
System.out.println(t);
}
finally
{
client.stop();
}
}
}
リモートサーバーに正常に接続しています。ここで、FTP サーバーに接続してファイルをダウンロードし、リモート サーバーに保存する必要があります。私はここで立ち往生しています。さらに実装する方法やコード、提案は素晴らしいでしょう。ありがとう