ということでJavaでCISCO VPN Client 用デスクトップ・アプリケーション(C-VPN Client)を作ってみました。
あくまでも操作専用画面なので事前にCISCO VPN Clientがインストールされている必要があります。
続きを読む
SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(9191); // // It's usually a good idea to give the host key generator a path, // so that if you restart the sshd server, the same key will be // used to authenticate the server. // sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); // auth object PasswordAuthenticator myAuthenticator = new MyPasswordAuth(); sshd.setPasswordAuthenticator(myAuthenticator); // // That's the part you will usually have to write to customize the SSHD server. // The shell factory will be used to create a new shell each time a user logs in. // SSHD provides a single implementation that you can use if you want. // This implementation will create a process and delegate everything to it, // so it's mostly useful to launch the OS native shell. // //sshd.setShellFactory(new ProcessShellFactory(new String[] { "cmd", "/c" })); sshd.setShellFactory(new ProcessShellFactory( new String[] { "/bin/sh", "-i", "-l" })); // // SSHD provides a CommandFactory to support SCP that can be configure // in the following way: /// sshd.setCommandFactory(new ScpCommandFactory()); try { sshd.start(); System.out.println("pure java sshd server started."); } catch (IOException e) { e.printStackTrace(); }
public class MyPasswordAuth implements PasswordAuthenticator { public boolean authenticate(String username, String password, ServerSession session) { System.out.println("username: "+username+", password: "+password); return true; } }
$ ssh -p 9191 username@localhost
The authenticity of host '[localhost]:9191' can't be established.DSA key fingerprint is 09:8b:d5:47:5d:c6:3a:c3:05:41:23:85:ad:f5:d0:fc.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '[localhost]:9191' (DSA) to the list of known hosts.username@localhost's password:sh: no job control in this shell
sh-3.00#
$ scp -P 9191 ~/Downloads/file.zip username@192.168.0.20:c:/tmp/tmp2.txtusername@192.168.0.20's password:htmlparser1_6_20060610.zip 100% 4244KB 2.1MB/s 00:02