A simple programmer trying to succeed... @pere_barcelo
Don't wanna be here? Send us removal request.
Text
Download and install a SSL certificate manually
openssl s_client -showcerts -connect www.domain.com:443 2>/dev/null | openssl x509 -out domain.pem
0 notes
Text
Check open ports without netstat or lsof
declare -a array=($(tail -n +2 /proc/net/tcp | cut -d":" -f"3"|cut -d" " -f"1")) && for port in ${array[@]}; do echo $((0x$port)); done
0 notes
Text
Open an application with arguments from the command line in MacOSX
$ open -a Meld --args dir1 dir2
0 notes
Text
SSH into your Virtualbox Guest
In case you have an Ubuntu Server as your Virtualbox Guest you won't be able to copy&paste from/to the Host. Even if you install the Guest Additions, due supposely to the fact that the Clipboard integration relies on having a running X server in the Guest.
Set up the Guest Network:
Go to menu Machine > Settings... > Network > button Advanced > button Port Forwarding
Specify a name, the Host address (ie 127.0.1.1) and port (2222), and the Guest address (ie 10.0.2.15, or whatever it is) (run ifconfig from a console in the Guest to know which one), and the port where the SSH server is running in the Guest (ie 22)
Then, from the Host, you can do:
$ ssh -p 2222 127.0.1.1
6 notes
·
View notes
Text
rsync to a specific port
Supose you want to rsync files to a server listening on port 2222. Then:
$ rsync -uva -e "ssh -p 2222" /path/to/files/* server:/remote/path/
0 notes
Text
Connect to MS SQL Server from your ubuntu box
Install the UNIX-ODBC tools:
$ sudo apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc freetds-bin
$ sudo vi /etc/freetds/freetds.conf
[ODBC_DSN] host = «THE IP OR THE SERVER NAME» port = 1433 tds version = 7.0 client charset = UTF-8
Test the connection works:
$ tsql -S ODBC_DSN -U «USER» -P «PASSWORD»
You will see a 1> prompt if the connection succeeded.
Define the driver:
$ sudo vi /etc/odbcinst.ini
[FREETDS_DRIVER] Description = "FreeTDS DRIVER" Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Define the Datasource name (DSN):
$ sudo vi /etc/odbc.ini
[ODBC_DSN] Description = "The description for your ODBC database connection" Driver = FREETDS_DRIVER Server = «THE IP OR THE SERVER NAME» Port = 1433 Database = «DATABASE»
Connect to the database and start querying:
$ isql -v ODBC_DSN «USER» «PASSWORD»
0 notes
Text
Mount ISO image under Linux
sudo mount -o loop the_file.iso /mnt
0 notes
Text
SSH Tunneling
Supose you want to reach the server on 199.199.199.199 at port 22 (the firewalled server) from your workplace where you don't have access to that server. On the other hand, you have access to 199.199.199.199 from the server at 200.200.200.200 which you can access from your workplace (the accessible server).
You can make a SSH tunnel so that you'll be able to access the server at 199.199.199.199 at port 22
Execute the command below in the accessible server:
ssh -f -L 0.0.0.0:3333:199.199.199.199:22 200.200.200.200 -N
-f Requests ssh to go to background just before command execution.
-L [bind_address:]port:host:hostport Specifies that connections to the given TCP port (3333) on the local host (accessible server) (0.0.0.0 tells ssh to bind to all interfaces) are to be forwarded to the given host and port (firewalled server) (199.199.199.199 and port 22), on the remote side.
-N Do not execute a remote command.
You'll be asked for your password at the accessible server. After that, you can access to the firewalled server from your workplace accessing to 200.200.200.200 at port 3333
0 notes
Text
Set the HTTP/HTTPS proxy to be used by the JVM
(I always forget the right syntax)
Use this from the command line:
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8080
Or programmatically:
System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty("http.proxyPort", "8080"); System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty("https.proxyPort", "8080");
0 notes
Text
Find out the name of the SSID you are connected to
Use this:
$ iwgetid -r
Or this:
$ nmcli -t -f active,ssid dev wifi | egrep '^yes' | cut -d: -f2
0 notes
Text
Diff the output of two commands
$ diff <(ls dir1) <(ls dir2)
0 notes
Text
Disable an Unix/Linux account
Disable the account NOW (replace 1 with a YYYY-MM-DD date if you want to disable the account on a specific date)
# usermod --expiredate 1 USERNAME
Additionally, you can lock his password (note that this does not prevent the user to still login using SSH keys)
# passwd USERNAME -l
0 notes
Text
Use sshfs to mount an AWS EC2 folder using PEM file
$ sshfs -o "IdentityFile=path/to/file.pem" ubuntu@EC2_HOST:/path/to/dir /path/to/mount/point
0 notes
Text
Trust Burp Proxy certificate in Debian/Ubuntu
To allow the use of wget or other command line tools with Burp Proxy when calling SSL pages you have to trust the Burp certificate.
Proceed doing:
Go to the Proxy tab in Burp the subtab Options click on the CA Certificate... button and export Certificate in DER format
Then:
# In the Debian/Ubuntu local store $ openssl x509 -in burp.der -inform DER -out burp.pem -outform PEM $ sudo chown root:root burp.pem $ sudo chmod 644 burp.pem $ sudo cp burp.pem /usr/local/share/ca-certificates/ $ sudo c_rehash # In the system store $ cd /etc/ssl/certs/ $ sudo ln -s /usr/local/share/ca-certificates/burp.pem $ sudo c_rehash .
See more: http://mcarpenter.org/blog/2012/10/25/trusting-3rd-party-certificates-on-ubuntu
0 notes
Text
Download/mirror a web page including CSS, JS and images
$ wget --no-parent --timestamping --convert-links --page-requisites --no-directories --no-host-directories -erobots=off URL
0 notes
Text
Avoid enter the password using Postgres CLI tools
Create a $HOME/.pgpass file:
*:*:*:username:secret
Make it readable (400) or read-write (600) only for you:
$ chmod 400 $HOME/.pgpass
The postgres CLI tools will use this method just adding the -w (--no-password) option and will not prompt for your password.
0 notes
Text
Fix annoying ‘perl: warning: Setting locale failed.‘
If you ever see this annying message:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_TIME = "en_GB.UTF-8", LC_MONETARY = "en_GB.UTF-8", LC_ADDRESS = "en_GB.UTF-8", LC_TELEPHONE = "en_GB.UTF-8", LC_NAME = "en_GB.UTF-8", LC_MEASUREMENT = "en_GB.UTF-8", LC_IDENTIFICATION = "en_GB.UTF-8", LC_NUMERIC = "en_GB.UTF-8", LC_PAPER = "en_GB.UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_ALL to default locale: No such file or directory
Fix it doing:
# apt-get install --reinstall language-pack-en # locale-gen # dpkg-reconfigure locales # echo 'LC_ALL="en_GB.utf8"' >> /etc/environment
0 notes