-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSSH_Commands.txt
261 lines (228 loc) · 8.4 KB
/
SSH_Commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
FILE: SSH_Commands.txt
AUTHOR: Zaid Pirwani
PURPOSE: a log of ALL things done on RasBhariPi, mostly via the SSH
#define ZP ZaidPirwani.com
FORMAT
command written like this
text inside a file is written like this
// this is a comment
[a blank line means topic change, command change, or just sometyhing else]
sudo raspi-config
changed password, ask ZP
changed hostname: RaspBhariPi
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install tightvncserver
mkdir rtc
cd rtc
// from http://www.suptronics.com/RPI.html
// for RTC and STUFF
wget http://www.suptronics.com/downloads/rtc-3.6.11.tar.gz
tar xzvf rtc-3.6.11.tar.gz
sudo dpkg -i rtc-3.6.11.deb
sudo cp /boot/vmlinuz-3.6.11-atsw-rtc+ /boot/kernel.img
sudo nano /etc/modules
i2c-bcm2708
rtc-pcf2127a
sudo nano /etc/rc.local
echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
( sleep 2; hwclock -s ) &
sudo reboot
sudo date MMDDHHMMYYYY.SS
sudo hwclock -w
sudo hwclock -r
sudo hwclock -s
//from http://raspberrypihq.com/how-to-share-a-folder-with-a-windows-computer-from-a-raspberry-pi/
sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf
workgroup = WORKGROUP
wins support = yes
mkdir ~/share
sudo nano /etc/samba/smb.conf
[RasBharaShare]
comment=Shared folder on RaspBhariPi
path=/home/pi/share
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
sudo smbpasswd -a pi
sudo apt-get install build-essential python-rpi.gpio python-dev python-smbus i2c-tools git-core arduino
sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.1
// REMOVED [the above settings]
// the PTCL Router reserves the IP 192.168.1.2 for Raspberry Pi by means of matching MAC at DHCP
// the PTCL Router is also setup to forward ports 9000 to 9100 to Raspberry Pi
// the usual ports are OPEN via the router by an offset of 9000
// SSH = 9022
// HTTP = 9080
// there are 3 files on the server inside a folder and a PAGE on Ejaad's site
// FOLDER: http://ejaad.com.pk/RasBhariPi
// FILES
// reportIP.php: records the IP of anyone who tries to access this file, the Raspberry Pi tries to GET this file at every reboot
// ^--- should password protect this somehow (maybe a URL argument to check before logging the IP address), else anyone accessing this will change the server IP
// IPlog.txt: the log file for IPs, also contains the date/time of the IP
// ^--- this file is only accessible by the script running on server, not from outside
// index.php: queries the IPlog.txt and gets the last line from it (the newest record), extracts the IP from the last line and REDIRECTS to that IP
// Wordpress Page: a page on ejaad's website, has an iframe pointing to index.php inside the RasBhariPi folder
// ACCESS URLS
// http://RASPBHARIPI'sIP OR add :80OR add:9080
// http://ejaad.com.pk/RasBhariPi:9080 --> will open the actual http site on Raspberry Pi
// http://ejaad.com.pk/rasbharipi:9080 --> will open the actual http site of Raspberry Pi inside an iframe
sudo nano /etc/ssh/sshd_config
Port 9022
//http://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
sudo apt-get install apache2
sudo nano /etc/apache2/ports.conf
NameVirtualHost *:9080
Listen 9080
netstat -lntp
sudo nano /var/www/index.html
sudo apt-get install php5 libapache2-mod-php5
// Ping the server on every reboot, to save IP
sudo crontab -e
@reboot sleep 60 && wget http://ejaad.com.pk/RasBhariPi/reportIP.php
sudo apt-get install twidge
twidge setup
// apparently Twiiter API changed, twidge udpated but the debian package is still OLD
// building from source requires the NEW haskell compiler, which is also old and also requires something else
// so no twidge.. :(
// from: http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=47553
sudo apt-get remove twidge
// need to tweet from Pi..
// http://twitter.com/rasbharipi
// from: https://github.com/ryanmcgrath/twython
sudo apt-get install python-setuptools python-pip
sudo pip install twython
// was NOT working, path not set or something
sudo pip uninstall twython
git clone git://github.com/ryanmcgrath/twython.git
cd twython
python setup.py install
// to keep an eye on the apache logs and deny access to those with malicious intent
// on suggestion from: http://www.raspberrypi.org/forums/viewtopic.php?f=41&t=83333&p=589369#p589369
sudo apt-get install fail2ban
// following (some of the) steps from here: http://www.pontikis.net/blog/fail2ban-install-config-debian-wheezy
// no webmin rule or w00t-w00t rule
sudo nano /etc/default/fail2ban
FAIL2BAN_OPTS="-x"
// Added system status script from http://derkev.in/rpisysinfoscript/
// Saved as /var/www/temp.php
sudo nano /var/www/temp.php
// added link to script in /var/www/inedx.html
sudo nano /var/www/temp.php
// installed wiringPi from: http://wiringpi.com/download-and-install/
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
// to check status of all pins: gpio readall
// Instaling WebIOPi
// from: https://code.google.com/p/webiopi/wiki/INSTALL
wget http://cznic.dl.sourceforge.net/project/webiopi/WebIOPi-0.7.0.tar.gz
tar xvzf WebIOPi-0.7.0.tar.gz
cd WebIOPi-0.7.0
sudo ./setup.sh
sudo nano /etc/webiopi/config
[HTTP]
enabled = true
port = 9009
passwd-file = /etc/webiopi/passwd
doc-root = /home/pi/webiopi/examples/scripts/macros
welcome-file = index.html
sudo webiopi-passwd
login: piWebIO
password: ask ZP
// start on Boot
sudo update-rc.d webiopi defaults
// Ping the server every hour, to save IP
// cront tab is: m h dom mon dow command
sudo crontab -e
0 * * * * wget http://ejaad.com.pk/RasBhariPi/reportIP.php
// Add the www folder of Apache to Samba local shares for easy access
sudo nano /etc/samba/smb.conf
[RasBharaServer]
comment=Apache HTTP Server (www) folder on RasBhariPi
path=/var/www/
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
// NEW COMMAND; to view Kernal Rign Buffer messages
dmesg | tail
// seems to be all messages regarding device drivers
// TorrentBox - using Deluge
// from: http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/ (not completely followed)
// deluged is the main daemon
// deluge-console is the SSH/command line way
// allow_remote allows the deluge on pi to be used via a deluge installed on desktop
// Web-Ui is needed to put deluge as an HTTP server
sudo apt-get install deluged deluge-console
deluged
sudo pkill deluged
sudo nano ~/.config/deluge/auth
pi:ask ZP:10
deluged
deluge-console
config -s allow_remote True
config allow_remote
exit
sudo pkill deluged
deluged
// setting up WebUI
sudo apt-get install python-mako deluge-web
deluge-web
// default port is 8112, default password is: deluge
// opened RaspberryPiIP:8112,
// changed the port to 9012
// changed the password too, ask ZP for it
// set the Downloads folder to /home/pi/Torrr
// set the Add Torrents from folder to /home/pi/Torrr
// set the max download speed 40Kibps
// set the max upload speed 4Kibps
// set Active Torrents to 1
// scripts for starting deluge on boot
sudo wget -O /etc/default/deluge-daemon http://cdn8.howtogeek.com/wp-content/uploads/gg/up/sshot5151a8c86fb85.txt
sudo nano /etc/default/deluge-daemon
sudo chmod 755 /etc/default/deluge-daemon
sudo wget -O /etc/init.d/deluge-daemon http://cdn8.howtogeek.com/wp-content/uploads/gg/up/sshot5151aa042ad11.txt
sudo chmod 755 /etc/init.d/deluge-daemon
sudo update-rc.d deluge-daemon defaults
// the files are also saved on git, replace _ with /
// in folder: deluge_scripts
sudo reboot
// Add the Torrr folder to Samba local shares for easy access
sudo nano /etc/samba/smb.conf
[Torrr]
comment=Torrr folder on RasBhariPi
path=/home/pi/Torrr
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
// Formatting the SD Card to NTFS
// first installing ntfsprogs to enable ntfs formatting from gparted
sudo apt-get install ntfsprogs
// use df -h to find out the correct drive
// use gparted to do the formatting from GUI, just to be sure
// use VNC for gui (should be already installed)
// setting up Auto Mounting of SD Card
sudo mkdir /media/shared
sudo nano /etc/fstab
/dev/sda1 /media/shared ntfs 0 0
// Update and upgrade Raspbian (to solve eluge problems)
// deluge stops downloading, need to upgrade it, also upgrading raspbian
// need to NOT download wolfram-engine, putting a hold on it
sudo apt-mark hold wolfram-engine
sudo apt-get update
sudo apt-get upgrade