Labels
amazon
apache
apt
aptitude
automate docker image
awk
aws
awstat
backup
bandwidth
bash
binary log
bond
bridge
caching
centos
centos 7
cluster
concurrency
csv
digitalocean
disk
django
docker
docker images
dovecot
drop cache
enviroment
error
explain
free
fstab
ftp
git
gluster
go
gpg
grep
grub
header
header check
icinga2
imapsync
information
innodb
ip
iproute
isolation
ispconfig
java
jenkins
jump
kdump
keepalived
kvm
linux
locale
logbuffer
lookbehind
macos
mail
maillog
matplotlib
mcrypt
memory
modrewrite
monitoring
mount
msyql ndbcluster
mta
multipath
mutt
my.cnf
mysql
mysql error
mysql optimization
mysql permission
mysqlcluster
mysqldump
nethogs
network
nginx
node
nopasswd
ntp
nxlog
openssl
optimization
parsing
parted
password
pflogsumm
php
php-fpm
php5-mcrypt
phpmyadmin
pip
policyd
post
postfix
proxy
pycurl
python
query_cache
querydict
rdesktop
rds
recommender systems
recover mysql
redhat
redolog
regex
regularexpression
resilver
roundcube
route
rsync
scrapy
script
scrub
security
service
setfacl
sftp
slow
smtp
snnp
spamassassin
spotlight
sql
squirrelmail
ssc
ssh
ssh-copy-id
ssl
startup
syslog
syslog over tls
tar
telnet
tls
tomcat
transaction
troubleshoot
tuning
ubuntu
udev
ulimit
usb
vdev removal
virtualhost
virtualization
virtualmin
vrrp
watch
webscrape
wget
x11
zfs
zfs send
zfs recv
zpool
Adding the Restricted SFTP User to the System
Sometimes it is needed to give access for a user to one and only one folder. For example, if your run a web hosting and your client ask you to give him access to his website's files. And you don’t have a control panel or FTP configured on your server.
There is a solution to it!
This lecture is about setting up SFTP users who’s access is restricted to their home directories.
As you have SSH set up and running, you also have the SFTP set up as well.
First of all, we need to add a new user to a home directory that this user will be restricted to. To do this, we run:
adduser --home /home/www/directory restricted_user
This will create a user restricted_user, the directory /home/www/directory and then set the permissions on the directory so the user can write to it. It won't have an ability to write to any other directory by default.
If you have a sort of web hosting, then you probably have already user's "home" directory with files in it. Then you need to add --no-create-home option to adduser command:
adduser --no-create-home restricted_user
You will be prompted for some additional information about the user being created and for the user's password.
Now let's set user's group:
usermod steve -g sftponly
To deny SSH shell access, run the following command:
usermod steve -s /bin/false
After the user was created and tuned, we need to make changes to /etc/ssh/sshd_config file. In some configurations, it may be located in /etc/sshd_config (just for info).
Add the following to the end of the /etc/ssh/sshd_config file:
Subsystem sftp internal-sftp
Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
Make sure that "Match…" block is placed at the very end of sshd_config file.
This block makes sure that all users in the ‘sftponly’ group will be chrooted to their home directory, where they only will be able to run internal SFTP processes.
Finally, we need to restart SSH:
sudo service ssh restart
After that, the SSH side should be in order, but you should make sure that file permissions are correct as well. Make sure that both /home and /home/username directories are owned by root and have permissions along the lines of 755 or 750. We want to be sure that every folder leading up to and including the home folder must be owned by root. If that's not the case we will get the "Broken pipe" or "Connection reset by peer" error after logging in.
part 1 Continuous delivery/ Continuous integration
CD: practice of creating repeatable, reliable process for releasing software
CD : Release often, release faster , greater reliablility
- innovative,fast feedback,warranty
- faster bug discovery and fixes
Outcome
- unit and integration tests using Docker
- Build and testing docker release images
- push button style automation for continuous delivery and deployment
- Continuous delivery pipeline using Jenkins 2.0
- Setup a deployment pipeline that deploy applicatin to AWS
- Build production class continuous delivery workflow
CI/CD for ...
Operation guys:
build continuous delivery pipeline
automate test,build,release and deploy
Infrastructure as a Code
Architects:
application agonistic method(crossplatform/interoperability)
run on any CD system like jenkins
immutable infrastructure
Infrastructure as code
Developers:
wrap test and build actions
your application works any machine
run production like env locally
fast track your changes in production
CD Architecture and Workflow
1) Testing stage (unit and integration test)
Use docker to wrap test runners
2) Build stage
eg. python wheel, java jar files
This must represent as tested application state
create deployable artifact
-- precompiled and pre built
-- installation requires no development dependencies
3) Release Stage
Build Docker Release image
- Includes minimum runtime enviroment
- install application artifacts
Release Enviroment
- Production like enviroment
- Use external test runner to run acceptance test
Tag and Publish
- only if acceptance test pass
- docker HUB
CD : Release often, release faster , greater reliablility
- innovative,fast feedback,warranty
- faster bug discovery and fixes
Outcome
- unit and integration tests using Docker
- Build and testing docker release images
- push button style automation for continuous delivery and deployment
- Continuous delivery pipeline using Jenkins 2.0
- Setup a deployment pipeline that deploy applicatin to AWS
- Build production class continuous delivery workflow
CI/CD for ...
Operation guys:
build continuous delivery pipeline
automate test,build,release and deploy
Infrastructure as a Code
Architects:
application agonistic method(crossplatform/interoperability)
run on any CD system like jenkins
immutable infrastructure
Infrastructure as code
Developers:
wrap test and build actions
your application works any machine
run production like env locally
fast track your changes in production
CD Architecture and Workflow
1) Testing stage (unit and integration test)
Use docker to wrap test runners
2) Build stage
eg. python wheel, java jar files
This must represent as tested application state
create deployable artifact
-- precompiled and pre built
-- installation requires no development dependencies
3) Release Stage
Build Docker Release image
- Includes minimum runtime enviroment
- install application artifacts
Release Enviroment
- Production like enviroment
- Use external test runner to run acceptance test
Tag and Publish
- only if acceptance test pass
- docker HUB
Practical use of git
git remote add origin https://github.com/devopsnep/localhost.git
git push -u origin master
git fetch // retrive changes from remote repo ,store them but dont include in local code
git merge
"git pull" is same as "git fetch && git merge"
git branch new-feature
git branch //shows branches
git checkout new-feature // switch to branch called new-feature
git add -A
git commit -m "added new features"
git branch is extremely useful for developing features or bugfixes in isolation
and it can be merged to the central branch
git checkout -b new-feature2 //create branch and switch to it
git checkout - // similar to 'cd -'
To merge the branch "new-feature" to "master"
git checkout new-feature
// do some changes git add -A and commit
git checkout master
git merge new-feature
// To delete the branch
git branch -d new-feature
###automatic merge fail cases and merge CONFLICT'S:
git status //see which file have conflicts and then open that file
open file in editor and make changes and add+commit+push
##git stash
objective is to leave the current uncommitted code as is
create new bugfix branch do corrections and merge
get back to uncommittted incomplete code and continue
git checkout -b monthadd
vim month.php
..
git add -A //stage the changes
## bugfix need to be done
git stash ## yesley garirako change lai side lagaucha
git checkout -b bugfixes
//do stuffs
git checkout master
git merge bugfix
// now getting backto leftover code/branch called "months"
git checkout months
git stash apply // gets back the incomplete code/files
..do coding
git commit -m "months feature added"
git status
..
// done
// Example
git log --oneline // condenses commits to single line
git log --decorate
git log --graph // ASCII graph shows branches and merges
git log -p //patch / shows lines deleted and added
git log --start //show number of insertion/deletions
git log --oneline --graph
git log -3 //show 3most recent commit
git log --after="yesterday" //commit between now and yesterday
git log --after="2 weeks ago"
git log --after="2/15/17"
git log --after="2-15-17"
git log --after="2-15-17" --before="yesterday"
git log -i --author="Trevor\|Jane" //filters by author name/email containing work "trevor" or "jane" here -i is ignore case
git log --grep="copyright" // finds commit that has word copyright
git log -p -S"Math" //find commit code change that has word "Math" is removed or added
git log -p -GMath\|Random //same as but using regex to find commit code change that has word Math is removed or added
git log LICENSE.md README.txt //see commits for these two files
git log master..new-feature // see where master and new-feature branch is diverged
## view and rename remotes
git remote -v
# View existing remotes
origin https://github.com/OWNER/REPOSITORY.git (fetch)
origin https://github.com/OWNER/REPOSITORY.git (push)
git remote rename origin destination
# Change remote name from 'origin' to 'destination'
git remote -v
# Verify remote's new name
destination https://github.com/OWNER/REPOSITORY.git (fetch)
destination https://github.com/OWNER/REPOSITORY.git (push)
Free memory drop cache in linux os
Drop Caches
Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache...
# echo 1 > /proc/sys/vm/drop_caches
# echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run "sync" first to flush them out to disk, these drop operations will tend to free more memory.
linux, web, ispconfig3, python, bash, apache
drop cache,
free,
memory
part 1 Tomcat 9 and Jenkins installation
First install java 8/1.8
Step 1: Add the repository
At the time of writing, Java 8 is not in the sources list by default, so we have to add the "Webupd8" repo, which contains Java 8.
add-apt-repository ppa:webupd8team/java
Step 2: Update the repository list
apt-get update
Step 3: Install
Run the following command to install Java 8:
apt-get install oracle-java8-installer
During the installation, you will need to agree to the Oracle license. This is as simple as selecting "yes" and hitting "enter".
Step 4: Verify installation
Execute this command to check that the installation was successful:
java -version
... and you will output similar to the following (depending on the current version of Java 8).
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Install Tomcat 9wget http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M22/bin/apache-tomcat-9.0.0.M22.tar.gz
tar xvfz apache-tomcat-9.0.0.M22.tar.gz
mv apache-tomcat-9.0.0.M22 /opt/tomcat9
cd /opt/tomcat9
vim conf/tomcat-users.xml
#add below before the </tomcat-users> ends
..
..
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="eudreka" password="urgen123#" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
..
</tomcat-users>
./bin/startup.sh
OR
/opt/tomcat9/bin/startup.sh
To verify point your browser to http://202.94.66.59:8080/
You will get 404 Access Denied error if not on same server , to solve this edit context.xml
vim /opt/tomcat9/webapps/manager/META-INF/context.xml
#comment out the lines like below---
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
Setup Jenkins [latest stable version]
cd /opt/
wget http://mirrors.jenkins.io/war-stable/latest/jenkins.war
http://202.94.66.59:8080/manager/html
<give username password>
See : jenkins version 2.60
Install plugins for jenksins
Setup the password
http://202.94.66.59:8080/jenkins
cat /root/.jenkins/secrets/initialAdminPassword
f8798282a2ba417bbc78edsdfdsf34c5
...Now paste the password to jenkins login and reset password
Now click on install on suggested plugins..
Fillup the form and create admin user
End
Part 2 virtualmin , roundcube installation password change plugin
virtualmin > edit server > makesure mysql is enabled

Virtualmin > Server Configuration > website options

If there is any change in the user permission or group name enter:-
chown root.VIRTUAL_SERVER_GROUP_NAME plugins/password/helpers/chgvirtualminpasswd
strip plugins/password/helpers/chgvirtualminpasswd
chmod 4550 plugins/password/helpers/chgvirtualminpasswd
$username = escapeshellarg($username);
/** $domain = escapeshellarg($domain); **/
$domain = "axonadvisers.com";
$newpass = escapeshellarg($newpass);
$curdir = RCUBE_PLUGINS_DIR . 'password/helpers';
/** exec("$curdir/chgvirtualminpasswd modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue); **/
// /home/axonadvisers/public_html/roundcube/plugins/password/helpers
exec("/home/axonadvisers/public_html/roundcube/plugins/password/helpers/chgvirtualminpasswd modify-user --domain axonadvisers.com --user $username --pass $newpass", $output, $returnvalue);

Virtualmin > Server Configuration > website options

If there is any change in the user permission or group name enter:-
chown root.VIRTUAL_SERVER_GROUP_NAME plugins/password/helpers/chgvirtualminpasswd
strip plugins/password/helpers/chgvirtualminpasswd
chmod 4550 plugins/password/helpers/chgvirtualminpasswd
if above doesnt work then ....
vim /home/axonadvisers/public_html/roundcube/plugins/password/drivers/virtualmin.php
/** $domain = escapeshellarg($domain); **/
$domain = "axonadvisers.com";
$newpass = escapeshellarg($newpass);
$curdir = RCUBE_PLUGINS_DIR . 'password/helpers';
/** exec("$curdir/chgvirtualminpasswd modify-user --domain $domain --user $username --pass $newpass", $output, $returnvalue); **/
// /home/axonadvisers/public_html/roundcube/plugins/password/helpers
exec("/home/axonadvisers/public_html/roundcube/plugins/password/helpers/chgvirtualminpasswd modify-user --domain axonadvisers.com --user $username --pass $newpass", $output, $returnvalue);
restart httpd
and DONE
linux, web, ispconfig3, python, bash, apache
roundcube,
virtualmin
Part 1 Virtualmin installation on centos 7.3
set FQDN for hostname
yum -y update
yum install epel-release
yum install wget curl rsync gcc -y
wget http://software.virtualmin.com/gpl/scripts/install.sh -O /tmp/virtualmin-install.sh
cd /tmp
#Add mysql repository to your centos 7
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum install mysql-server -y
chmod +x /tmp/virtualmin-install.sh
bash /tmp/virtualmin-install.sh
done
login to virtualmin using https://<ip>:10000
Install roundcube
https://www.virtualmin.com/documentation/id%2Cwebmail_and_virtualmin
Make sure to enable mysql in website settings or See here
http://urgenphp.blogspot.com/2017/07/part-2-virtualmin-roundcube.html
yum -y update
yum install epel-release
yum install wget curl rsync gcc -y
wget http://software.virtualmin.com/gpl/scripts/install.sh -O /tmp/virtualmin-install.sh
cd /tmp
#Add mysql repository to your centos 7
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum install mysql-server -y
chmod +x /tmp/virtualmin-install.sh
bash /tmp/virtualmin-install.sh
done
login to virtualmin using https://<ip>:10000
- Login to Virtualmin, and click on Webmin at the top of the left menu.
- Open the Webmin category, click on Usermin Configuration, then on Usermin Module Configuration, and finally on Read Mail.
- On the form that appears, change the Mail storage format for Inbox to Maildir.
- Click Save.
cp /etc/postfix/main.cnf /etc/postfix/main.cnf.BAK
sudo postconf -e 'smtp_tls_security_level = may'
sudo postconf -e 'smtpd_tls_security_level = may'
sudo postconf -e 'smtp_tls_note_starttls_offer = yes'
sudo postconf -e 'smtpd_tls_security_level = may'
sudo postconf -e 'smtp_tls_note_starttls_offer = yes'
service saslauthd restart
https://www.virtualmin.com/documentation/id%2Cwebmail_and_virtualmin
Make sure to enable mysql in website settings or See here
http://urgenphp.blogspot.com/2017/07/part-2-virtualmin-roundcube.html
Install a Roundcube Password plugin in Virtualmin
- Install the Roundcube script usually from Virtualmin dashboard by selecting server and then going into Install Scripts->Roundcube from the Available Scripts and install it the way you require by selecting the sub folder you wish to install
- Now Log into the server over SSH with the virtualmin username and password you created during creation of the virtual server. Go into the sub directory you just installed Roundcube script into. We are assuming you selected folder name as roundcube .Now navigate into path from server via SSH as
cd /home/USERNAME/public_html/roundcube/ - Edit config/main.inc.php, and change this line:
$rcmail_config['plugins'] = array('virtuser_file');To this line:$rcmail_config['plugins'] = array('virtuser_file', 'password'); - Setup the password plugin config file with the help of this command in SSH in the roundcube folder:
cp plugins/password/config.inc.php.dist plugins/password/config.inc.php - Enable Virtualmin driver. To do that, go ahead and edit “plugins/password/config.inc.php”, and change this line:
- Compile C wrapper with this command ,If gcc is not installed,install it by using command if you are in Centos
yum install gccand then typegcc -o plugins/password/helpers/chgvirtualminpasswd plugins/password/helpers/chgvirtualminpasswd.c - Permissions are required by roundcude password plugin to access and change virtualmin functions so enter
chown root.VIRTUAL_SERVER_GROUP_NAME plugins/password/helpers/chgvirtualminpasswdstrip plugins/password/helpers/chgvirtualminpasswdchmod 4550 plugins/password/helpers/chgvirtualminpasswd - Fix syntax error in virtualmin.php driver by editing “plugins/password/drivers/virtualmin.php”, and jump to
line 54. You’ll see a line with just “break”. That line should end with a semicolon (;) character.The line should look like this:break; - You should now be able to log into RoundCube, go into Settings -> Password, and change your user’s roundcube password
$rcmail_config['password_driver'] = 'sql';
To this:
$rcmail_config['password_driver'] = 'virtualmin';
linux, web, ispconfig3, python, bash, apache
centos 7,
virtualmin
Subscribe to:
Posts (Atom)



