Showing posts with label snippet. Show all posts
Forward tcp port on other device to localhost
In this example script ssh port is 2231,
plink forwarding port 3306 to localhost port 3306
@echo off
setlocal

:: Replace with your actual values
set "USER=dev"
set "HOST=dev.mangapul.com"
set "PASSWORD=V3r1HardP4$$w0Rd"
::set "COMMAND=ls -l"

:: Construct the plink command
:: plink -ssh %USER%@%HOST% -pw %PASSWORD% %COMMAND%

:: -pw password
:: -P  connect to specified port
:: -N  don't start a shell/command (SSH-2 only)

:: plink -ssh -L 127.0.0.1:3306:dev.mangapul.com:3306 dev@dev.mangapul.com -P 2231 -pw V3r1HardP4$$w0Rd -N

plink -ssh -L 127.0.0.1:3306:%HOST%:3306 %USER%@%HOST% -P 2231 -pw %PASSWORD% -N


if %ERRORLEVEL% equ 0 (
    echo Command executed successfully.
) else (
    echo Command execution failed.
)

endlocal

Read more »

Here is an example using sed to remove
the ^M carriage returns from a file.

# inplace (works!)
sed -i "s/\r//g" windows-text-file.txt
sed -e "s/^M//" filename > newfilename
Read more »
openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout d:\tobasa.local.selfsigned.key -out d:\tobasa.local.selfsigned.crt

Read more »
From .pfx
-----------------
openssl pkcs12 -in d:\temp\tobasaapp.pfx -clcerts -nokeys -out d:\temp\certificate.crt

openssl pkcs12 -in d:\temp\tobasaapp.pfx -nocerts -nodes -out d:\temp\private.key

openssl pkcs12 -in d:\temp\tobasaapp.pfx -out d:\temp\certificate.pem -nodes
To .pfx
-----------------
openssl pkcs12 -export -out certificate.pfx -inkey PrivateKey.key -in certificate.crt -certfile CACert.crt
Here:

Certificate.crt = Your-domain-Name.crt
CACert.crt = Certificate Authority Bundle
certificate.pfx is the new name of generated file
PrivateKey can be in .key or .txt format
Read more »

#!/bin/bash

for i in {1..10}; do wget http://www.mangapul.com > $i.html; done


for xx in `ls *.sql`;do bzip2 -9 $xx ; done

Read more »