apt-get update
apt-get install openvpn easy-rsa
gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz > /etc/openvpn/server.conf
vim /etc/openvpn/server.conf
uncoment:
# dh dh1024.pem
# push "redirect-gateway def1 bypass-dhcp"
# push "dhcp-option DNS 208.67.222.222"
# push "dhcp-option DNS 208.67.220.220"
# user nobody
# group nogroup
echo 1 > /proc/sys/net/ipv4/ip_forward
vim /etc/sysctl.conf
uncoment:
# net.ipv4.ip_forward=1
cp -r /usr/share/easy-rsa/ /etc/openvpn
mkdir /etc/openvpn/easy-rsa/keys
vim /etc/openvpn/easy-rsa/vars
#export KEY_COUNTRY="BG"
#export KEY_PROVINCE="bg"
#export KEY_CITY="Velingrad"
#export KEY_ORG="Home"
#export KEY_EMAIL="email60@abv.bg"
#export KEY_OU="MYOrganizationalUnit"
#export KEY_NAME="server"
openssl dhparam -out /etc/openvpn/dh2048.pem 2048
cd /etc/openvpn/easy-rsa
. ./vars
./clean-all
./build-ca
./build-key-server server
cp /etc/openvpn/easy-rsa/keys/{server.crt,server.key,ca.crt} /etc/openvpn
service openvpn start
./build-key client1
cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf /etc/openvpn/easy-rsa/keys/client.ovpn
#Configuration with script
#!/bin/bash
apt-get update &&
apt-get -y upgrade &&
apt-get -y install openvpn easy-rsa &&
gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz \
> /etc/openvpn/server.conf &&
cd /etc/openvpn/ &&
sed -i.bak -e 's/dh dh1024.pem/dh dh2048.pem/' -e \
's/;push "redirect-gateway def1 bypass-dhcp"/push "redirect-gateway def1 bypass-dhcp"/' -e \
's/;push "dhcp-option DNS 208.67.222.222"/push "dhcp-option DNS 208.67.222.222"/' -e \
's/;push "dhcp-option DNS 208.67.220.220"/push "dhcp-option DNS 208.67.220.220"/' -e \
's/;user nobody/user-nobody/' -e \
's/;group nogroup/group nogroup/' server.conf &&
echo 1 > /proc/sys/net/ipv4/ip_forward &&
sed -i.bak 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf &&
cp -r /usr/share/easy-rsa/ /etc/openvpn &&
mkdir -p /etc/openvpn/easy-rsa/keys &&
cd /etc/openvpn/easy-rsa &&
sed -i.bak 's/export KEY_NAME="EasyRSA"/export KEY_NAME="server"/' vars &&
openssl dhparam -out /etc/openvpn/dh2048.pem 2048 &&
cd /etc/openvpn/easy-rsa &&
. ./vars &&
./clean-all &&
./build-ca &&
./build-key-server server &&
cp /etc/openvpn/easy-rsa/keys/{server.crt,server.key,ca.crt} /etc/openvpn &&
service openvpn start &&
./build-key client1 &&
cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf /etc/openvpn/easy-rsa/keys/client.ovpn
client.ovpn се редактира с името на сървара
8.05.2016 г.
23.03.2016 г.
Make static arp with bash
#!/bin/bash
start=$1
end=$2
ar=/usr/bin/arping
arp=/usr/sbin/arp
echo "Start is $start and end is $end"
echo
start_end=${start##*.}
end_end=${end##*.}
for i in $(seq $start_end $end_end);do
$arp -s `$ar -I eth0 ${start%.*}.$i -c 1 |\
grep "Unicast" | awk -F" " '{print $4," ",$5}' |\
sed -e 's/\[//' -e 's/\]//'`
done
start=$1
end=$2
ar=/usr/bin/arping
arp=/usr/sbin/arp
echo "Start is $start and end is $end"
echo
start_end=${start##*.}
end_end=${end##*.}
for i in $(seq $start_end $end_end);do
$arp -s `$ar -I eth0 ${start%.*}.$i -c 1 |\
grep "Unicast" | awk -F" " '{print $4," ",$5}' |\
sed -e 's/\[//' -e 's/\]//'`
done
20.02.2016 г.
Remove empty space's from name of file
#!/bin/bash
DIRECTORY=/home/test
find $DIRECTORY -name "* *"|while read fname;do
new_name=`echo $fname | tr " " "_"`
if [ -e $new_name ];then
echo "Exists"
else
mv "$fname" $new_name
fi
done
DIRECTORY=/home/test
find $DIRECTORY -name "* *"|while read fname;do
new_name=`echo $fname | tr " " "_"`
if [ -e $new_name ];then
echo "Exists"
else
mv "$fname" $new_name
fi
done
31.12.2015 г.
Python run TeamViewer from ini file.
#---------------Import Modules-------------------
import subprocess, platform, os, ConfigParser, time
from Tkinter import *
from tkFileDialog import askopenfilename
#---------------Tkinter-------------------------
root = Tk()
root.title("TeamViewer_Parse_From_File")
root.geometry("300x550")
#Scrol bar settings
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )
#-------------Global Variable is here------------------
List_with_Server = []
Config = ConfigParser.ConfigParser()
Path = None
Path_To_Ini = None
Run = "TeamViewer.exe"
#--------------Check machine 86 or 64------------------
if platform.machine() == 'x86':
#global name
Path = "C:\\Program Files\\TeamViewer"
Path_To_Ini = "C:\\Program Files\\TeamViewer\\acc.ini"
else:
#global name
Path = "C:\\Program Files (x86)\\TeamViewer"
Path_To_Ini = "C:\\Program Files (x86)\\TeamViewer\\acc.ini"
#--------------Function is here------------------------
#--------------Load servers from file in windows-------
def Popalni():
global Path_To_Ini
global Path
global Run
global Config
global List_with_Server
os.chdir(Path)
ini_file = open(Path_To_Ini, 'r')
ini_file_content = ini_file.read().strip()
Config.read(Path_To_Ini)
List_with_Server = list(Config.sections())
for i in (Config.sections()):
mylist.insert(END,i)
mylist.see(END)
mylist.update()
def Open_Directory():
"""Use for add additional file"""
name = askopenfilename()
subprocess.Popen(["notepad.exe", name])
#----------After click on server name load param to begin---
def choose():
firstIndex = mylist.curselection()[0]
global Choiced_Name
global Config
Choiced_Name = List_with_Server[firstIndex]
option = Config.options(Choiced_Name)
ID_Server = Config.get(Choiced_Name, "User")
Password_Server = Config.get(Choiced_Name, "Password")
p = subprocess.Popen(Run+" -i " + ID_Server + " --Password " + Password_Server, shell=True)
time.sleep(2)
p.kill()
root.destroy()
#Menu Bar settings
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Load_All", command=Popalni)
filemenu.add_command(label="Open_Ini_File", command=Open_Directory)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="Menu", menu=filemenu)
root.config(menu=menubar)
mylist = Listbox(root, yscrollcommand = scrollbar.set , bg="lightblue")
frame=Frame(root)
frame.pack()
#Label(text="Anchor").pack(side=LEFT)
chooseButton = Button(frame, text="Load_List", command=Popalni ,bg="lightgreen")
chooseButton.pack(side=LEFT,anchor=NW)
chooseButton1 = Button(frame, text="Run_ID", command=lambda:choose(), bg="lightgreen")
chooseButton1.pack(anchor=NW)
mylist.pack( side = LEFT, fill = BOTH, expand=1 )
scrollbar.config( command = mylist.yview )
#-----------------Take the magic--------------------
if __name__ == "__main__":
mainloop()
The ini file called "acc.ini" is in the following form:
[First_Id]
User=111111111
Password=Password
[Second_ID]
User=222222222
Password=Password
11.12.2015 г.
How to wathc and listen movie and mp3 from another machine
Install virtual mashine or not you are choice:
install samba server
apt-get isntall samba
#config of samba share and add to the end of file /etc/samba/smb.conf
[share]
comment = Borko share
path = /home/borko/share
valid users = borko
read only = no
writables = yes
gueest ok = no
On mashine where put file and connect to mashine install samba-client
To mount server use
mount -t cifs //ip/share-filder -o username=borko,password=wonderwand /tmp
If you use local network use mount if you whant to put file in other segment use ftp or another.
To downoad torrent file make use aria
get toorent file and add this in terminal:
aria2c http://zamunda.net/download.php/444449/torrent-name.torrent
In the same folder (may use ssh) start daemon:
python -m SimpleHTTPServer
In your broweser put ip from server and port 8000(default)
Watch movie or listen mp3 from your browser.
install samba server
apt-get isntall samba
#config of samba share and add to the end of file /etc/samba/smb.conf
[share]
comment = Borko share
path = /home/borko/share
valid users = borko
read only = no
writables = yes
gueest ok = no
On mashine where put file and connect to mashine install samba-client
To mount server use
mount -t cifs //ip/share-filder -o username=borko,password=wonderwand /tmp
If you use local network use mount if you whant to put file in other segment use ftp or another.
To downoad torrent file make use aria
get toorent file and add this in terminal:
aria2c http://zamunda.net/download.php/444449/torrent-name.torrent
In the same folder (may use ssh) start daemon:
python -m SimpleHTTPServer
In your broweser put ip from server and port 8000(default)
Watch movie or listen mp3 from your browser.
Абонамент за:
Публикации
(
Atom
)