private void connect(String ip, int port, String user, String key, String passphrase, Proxy proxy) throws JSchException {
jsch = new JSch();
jsch.addIdentity(key);
session = jsch.getSession(user, ip, port);
if (proxy != null)
{
if ("HTTP".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxyHTTP(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS5".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS5(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS4".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS4(proxy.getProxyIp(), proxy.getProxyPort()));
}
}
session.setUserInfo(new MyUserInfo(null, passphrase));
Properties conf = new Properties();
conf.put("StrictHostKeyChecking", "no");
session.setConfig(conf);
synchronized (JSch.class) {
session.connect(timeout);
}
}
java类com.jcraft.jsch.ProxySOCKS4的实例源码
JSchImpl.java 文件源码
项目:fit-ext-default
阅读 33
收藏 0
点赞 0
评论 0
SSHManager2.java 文件源码
项目:hmcScanner
阅读 30
收藏 0
点赞 0
评论 0
public void setProxySOCKS4(String proxy_host, int proxy_port, String proxy_user, String proxy_password){
proxySOCKS4 = new ProxySOCKS4(proxy_host, proxy_port);
if (proxy_user!=null)
proxySOCKS4.setUserPasswd(proxy_user, proxy_password);
proxyType=SOCKS4;
if (myLogger!=null)
myLogger.log(com.jcraft.jsch.Logger.DEBUG, "PROXY_SOCKS4 host="+proxy_host+"; port="+proxy_port+"; user="+proxy_user);
}
SftpJSchImpl.java 文件源码
项目:fit-ext-default
阅读 23
收藏 0
点赞 0
评论 0
public Response<String> connect(String ip,int port,String user,String passwd, Proxy proxy){
Response<String> resp = new Response<String>();
try {
jsch = new JSch();
session = jsch.getSession(user, ip, port);
if (proxy != null)
{
if ("HTTP".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxyHTTP(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS5".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS5(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS4".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS4(proxy.getProxyIp(), proxy.getProxyPort()));
}
}
session.setPassword(passwd);
Properties conf = new Properties();
conf.put("StrictHostKeyChecking", "no");
session.setConfig(conf);
session.connect();
ftps = (ChannelSftp) session.openChannel("sftp");
ftps.connect();
resp.setCode(Response.OK);
connected = true;
} catch (JSchException e) {
resp.setCode(Response.IO_EXCEPTION);
resp.setPhrase("SftpException: " + e.getMessage());
}
return resp;
}
SftpJSchImpl.java 文件源码
项目:fit-ext-default
阅读 30
收藏 0
点赞 0
评论 0
public Response<String> connect(String ip,int port,String user,String key,String passphrase, Proxy proxy) {
Response<String> resp = new Response<String>();
try {
jsch = new JSch();
jsch.addIdentity(key);
session = jsch.getSession(user, ip, port);
if (proxy != null)
{
if ("HTTP".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxyHTTP(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS5".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS5(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS4".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS4(proxy.getProxyIp(), proxy.getProxyPort()));
}
}
session.setUserInfo(new MyUserInfo(null,passphrase));
Properties conf = new Properties();
conf.put("StrictHostKeyChecking", "no");
session.setConfig(conf);
session.connect();
ftps = (ChannelSftp) session.openChannel("sftp");
ftps.connect();
connected = true;
resp.setCode(Response.OK);
} catch (JSchException e) {
resp.setCode(Response.IO_EXCEPTION);
resp.setPhrase("SftpException: " + e.getMessage());
}
return resp;
}
JSchImpl.java 文件源码
项目:fit-ext-default
阅读 37
收藏 0
点赞 0
评论 0
private void connect(String ip, int port, String user, String passwd, Proxy proxy)
throws JSchException {
jsch = new JSch();
session = jsch.getSession(user, ip, port);
session.setPassword(passwd);
if (proxy != null)
{
if ("HTTP".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxyHTTP(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS5".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS5(proxy.getProxyIp(), proxy.getProxyPort()));
}
else if ("SOCKS4".equalsIgnoreCase(proxy.getType()))
{
session.setProxy(new ProxySOCKS4(proxy.getProxyIp(), proxy.getProxyPort()));
}
}
Properties conf = new Properties();
conf.put("StrictHostKeyChecking", "no");
session.setConfig(conf);
synchronized (JSch.class) {
session.connect(timeout);
}
}