Search This Blog

Showing posts with label sftp. Show all posts
Showing posts with label sftp. Show all posts

Tuesday, May 16, 2017

Docker - Setup with Two Tomcat with Nginx / SFTP

imp commands
************
find / -name tomcat8


Oracle jdk 1.8
**************
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

#this will give all ip and other details
docker inspect


imp commands
+++++++++++++
docker run -it ubuntu
apt-get update
apt-get install vim
apt-get install net-tools
apt-get install python-software-properties
apt-get install software-properties-common
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java8-installer
apt-get install -y net-tools
apt-get update
apt-get install tomcat7 vim
echo $JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
vim /etc/default/tomcat7
# now ensure in tomcat7 file
# remove the comment
JAVA_HOME=/usr/lib/jvm/java-8-oracle
ifconfig
service tomcat7 start

wget localhost:8080

docker commit/push/pull
docker ps -a
docker commit
docker push drvijayy2k2/ubuntutomcat1
docker pull drvijayy2k2/ubuntutomcat1


to show all process - ps aux


Now instead of exiting the container, detach from it back to your terminal by typing:
ctrl-p then ctrl-q
(If you’re using gnu screen, remember it’s ctrl-a a ctrl-p, then ctrl-q)


uninstall
*********
sudo apt-get purge docker-engine
sudo apt-get autoremove --purge docker-engine

umount /var/lib/docker/overlay #check and remvoe all the containers
umount /var/lib/docker/overlay2

rm -rf /var/lib/docker # This deletes all images, containers, and volumes

dettach
ctrl + a + p + q

80, 8080,8081,8082, 8888 - opened for outside

tomcat1
docker run --name tomcat1 -p 8080:8080 -it drvijayy2k2/tomcat8
service tomcat8 start
wget localhost:8080
ctrl + a + p + q
browser - http://ip-1:8080/

you can change the root file
apt-get install vim
find / -name tomcat8
vi /var/lib/tomcat8/webapps/ROOT/index.html
vi /usr/share/tomcat8/startup.sh

tomcat2
docker run --name tomcat2 -p 8081:8080 -it drvijayy2k2/tomcat8
service tomcat8 start
wget localhost:8080
backgroun [ -d is not working] - ctrl + a + p + q
browser - http://ip-2:8081/


nginx
172.17.0.3
#sudo docker run --name docker-nginx -p 80:80 -d -v ~/docker-nginx/tml:/usr/share/nginx/html nginx

docker run --name ubuntu-nginx -it -p 80:80 drvijayy2k2/nginx
vi /etc/nginx/conf.d/default.conf
service nginx start
ctrl + a + p + q
browser http://ip-3
docker attach

#add host entry c:\windows\system32\drivers\etc\hosts
ip-3 docker.poc.com
open browser
http://docker.poc.com
#stop the tomcat to see or refersh, it will do the roundrobin by default

SFTP - ip-4
*******
docker run -it -p 8081:22 drvijayy2k2/sftp
service vsftpd start
service ssh start
ctrl + a p q

open winscp
type ur public ip ip-4
port 8081
user john
pwd test123

copy some files to www folder

Thursday, September 29, 2016

Upload a file to SFTP using java

package com.sftp;

import java.io.File;
import java.io.FileInputStream;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

/**
 * @author drvijay
 */

public class SFTPcallInJava
{

public static void main ( String [] args )
{
String SFTPHOST = "192.168.7.99";
int SFTPPORT = 2121;
String SFTPUSER = "vijayjava";
String SFTPPASS = "vijaytest123";
String SFTPWORKINGDIR = "/www/";

Session session = null;
Channel channel = null;
ChannelSftp channelSftp = null;

try
{
JSch jsch = new JSch ();
session = jsch.getSession ( SFTPUSER, SFTPHOST, SFTPPORT );
session.setPassword ( SFTPPASS );
java.util.Properties config = new java.util.Properties ();
config.put ( "StrictHostKeyChecking", "no" );
session.setConfig ( config );
session.connect ();
channel = session.openChannel ( "sftp" );
channel.connect ();
channelSftp = (ChannelSftp) channel;
channelSftp.cd ( SFTPWORKINGDIR );
File f = new File ( "D:/Temp/aamlog.txt" );
channelSftp.put ( new FileInputStream ( f ), f.getName () );
}
catch ( Exception ex )
{
ex.printStackTrace ();
}

}

}



NOTE - Add jsch-0.1.54.jar

Hit Counter


View My Stats