Diferencia entre revisiones de «Sysadmin»

De Furilo
Ir a la navegación Ir a la búsqueda
(Página creada con «## Change default SSH port <code> vi /etc/ssh/sshd_config # What ports, IPs and protocols we listen for Port 50683 /etc/init.d/ssh restart ssh [email protected] -p...»)
 
 
(No se muestran 18 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
## Change default SSH port
+
== Network ==
  
<code>
+
Check iptables rules ([https://www.linode.com/docs/security/firewalls/control-network-traffic-with-iptables source])
 +
<pre>sudo iptables -L -nv</pre>
  
 +
Ban ip with iptables
 +
<pre>sudo iptables -I INPUT -s 196.52.32.4 -j DROP</pre>
 +
 +
Show all active connections to Web server – sorted and unique ([https://www.blackmoreops.com/2014/09/25/find-number-of-unique-ips-active-connections-to-web-server/  source])
 +
<pre>
 +
netstat -antu | grep :80 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c
 +
</pre>
 +
 +
Check what processes are consuming active IPs
 +
<pre>
 +
sudo netstat -tunp
 +
</pre>
 +
 +
== Utilities ==
 +
 +
* http://pow.cx/
 +
 +
== MySQL backups ==
 +
 +
mysqldump -u USER -p your_database_name  | gzip >  your_database_name.sql
 +
 +
== Postgresql ==
 +
 +
* Start server in OS X: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
 +
* Stop: pg_ctl -D /usr/local/var/postgres stop -s -m fast
 +
* createuser USER
 +
* createdb DB
 +
 +
== Rails in production ==
 +
 +
* [https://gist.github.com/xhj/5938280 Deploy Rails App with Puma and Nginx via Mina]
 +
* [http://blog.mccartie.com/2014/08/28/digital-ocean.html Digital Ocean: Ubuntu, Nginx, Unicorn, Rails]
 +
* [http://www.cubicleapps.com/articles/ubuntu-rails-ready-with-nginx-unicorn Ubuntu, Rails ready, with nginx & unicorn]
 +
 +
== SSH ==
 +
 +
=== Change default SSH port + Prevent root user from loging in via SSH ===
 +
 +
<pre>
 
vi /etc/ssh/sshd_config
 
vi /etc/ssh/sshd_config
 +
PermitRootLogin no
 +
Port 50683
 +
/etc/init.d/ssh restart
 +
ssh [email protected] -p 50683
 +
</pre>
 +
 +
== Problems installing gems in Mac OS X ==
 +
 +
If error:
 +
 +
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
 +
 +
 +
Solution
 +
 +
* http://stackoverflow.com/questions/19638810/cant-install-debugger-gem-rails-mac-osx-mavericks
 +
 +
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install ...
  
# What ports, IPs and protocols we listen for
 
Port 50683
 
  
/etc/init.d/ssh restart
+
== Data ==
  
ssh username@hostname.com -p 50683
+
Transform MS Access file to CSV https://github.com/brianb/mdbtools
</code>
 
  
 +
== Mumumío ==
  
## Prevent root user from being able to log in via SSH
+
IP en .Vagrantfile
  
<code>
+
<pre>
vi /etc/ssh/sshd_config
+
vagrant up
 +
vagrant ssh
 +
cd /vagrant
 +
rails server
 +
</pre>
  
PermitRootLogin no
+
'''Deploy'''
  
/etc/init.d/sshd restart
+
merge de stage hacia develop, y luego de develop hacia master. Así:
  
</code>
+
<pre>
 +
git co develop
 +
git merge stage
 +
git co master
 +
git push # No te olvides del push!
 +
cap production deploy
 +
</pre>

Revisión actual del 20:57 12 nov 2017

Network

Check iptables rules (source)

sudo iptables -L -nv

Ban ip with iptables

sudo iptables -I INPUT -s 196.52.32.4 -j DROP

Show all active connections to Web server – sorted and unique (source)

netstat -antu | grep :80 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c

Check what processes are consuming active IPs

sudo netstat -tunp

Utilities

MySQL backups

mysqldump -u USER -p your_database_name | gzip > your_database_name.sql

Postgresql

  • Start server in OS X: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
  • Stop: pg_ctl -D /usr/local/var/postgres stop -s -m fast
  • createuser USER
  • createdb DB

Rails in production

SSH

Change default SSH port + Prevent root user from loging in via SSH

vi /etc/ssh/sshd_config
PermitRootLogin no
Port 50683
/etc/init.d/ssh restart
ssh [email protected] -p 50683

Problems installing gems in Mac OS X

If error:

clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]


Solution

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install ...


Data

Transform MS Access file to CSV https://github.com/brianb/mdbtools

Mumumío

IP en .Vagrantfile

vagrant up
vagrant ssh
cd /vagrant
rails server

Deploy

merge de stage hacia develop, y luego de develop hacia master. Así:

git co develop
git merge stage
git co master
git push # No te olvides del push!
cap production deploy