Category Archives: Howto Tutorials (EN)

Howto Tutorials English Contribution Howto’s and Tutorials technical contribution for Professionals

PuTTY SSH Port Forwarding

SSH Tunnel with PuTTY

PuTTY can produce more than just terminal sessions, with the option SSH port forwarding can be initialized in simple ways.

After PuTTY is started, you enter the IP of the target host under host name, or the server name, which is usually a firewall, a router or a host with a global IP address.

PuTTY Configuration

Here in our example, on the host 212.117.203.98, our PBX is made with the port forwarding to a SIP phone, and then configured via the web browser, the host can also be an FQDN of a DNS resolvable host.

PuTTY SSH port forwarding

In the lower part of SSH, the tunnel point is selected. After that, the starting point and the end point of the tunnel are entered:
Source port: 8888
Destination: 172.30.10.10

PuTTY SSH port forwarding

The action is completed with a click on Add. The data from the tunnel has now been adopted. The settings are saved above under Session by clicking on Save Permanent.

Clicking on Load and Open will establish the connection. The well-known terminal console opens with the prompt to log in. There you log in as a normal user, so the tunnel is established.

Now you open the web browser and enter the following localhost address https://127.0.0.1:8888/. After that, as here in our example, the login dialog of the SIP-Phone WebGUI begins, which we can now configure. Other ways to use SSH tunnels are available for Synology DS, SAN Memory, Unix/Linux Hosts, or Mac OS X.

Note. The SSH option AllowTcpForwarding yes must be enabled on the server, default is yes entered in the server configuration file /etc/ssh/sshd_config.

For the host behind a firewall, it must be accessible via port 22 Static NAT forward.

PuTTY can be used by passing numerous parameters.

PuTTY shortcut

Insert the following line as the target for the link:
“C:\Program Files (x86)\PuTTY\PUTTY. EXE” -l jolly -pw password -4 -L 8888:172.30.10.10:80 -X :0 -load PBX

Wherethe parameters mean the following:
-l the login name
-pw the password
-4 it should be used IPv4
-L of the Destination Port and the IP
-X for X11 forwarding
-load open saved session

Linux Top 20 useful Shell Commands

Linux command line examples from practice with 20 commonly used commands

You don’t want to see a complete list here, but there may be a start for some of the common Linux commands, useful for sysops and admins.

1. Translate ASCII character set to octal, decimal, and hexadecimal

$ man ascii
Illustration: man ascii

2. Output calendar to console

$ cal

Calendar view 6 months with week number

$ cal -n 6 -w

3. Edit binary hexadecimal in VIM

$ vi file
 :%!xxd
 ..
 :%!xxd -r
 :wq

4. Compare two files

$ diff -w file1.txt file2.txt
2c2.3
< Jacqueline --> C. Meier
> Jacqueline Mayer

5. Find content in files recursively using find

$ find . -type f -print0 | xargs -0 grep "mojito"

6. Send a file as e-mail

$ mail -s subject jacque@unblog.ch < notes.txt

7. Download multiple URLs from list

$ cat download-urls.txt | xargs wget -c

8. Remove duplicate lines with awk

$ awk '!($0 in array) { array[$0]; print }' temp

Line output of /etc/passwd with the same uid and gid

$ awk -F ':' '$3==$4' /etc/passwd

9. Conversion from Windows/DOS (CR/LF) to Unix (LF) format

$ sed 's/.$//' filename
# Text Search and Replace
$ sed -e s/dog/cat/g file.txt > file.new
# Deletes all blank lines
$ sed '/^$/d' filename
# Deletes spaces at the end of each line
$ sed 's/ *$//' filename

10. Recursive String Search in Files

$ grep -r "ramsch" *

11. How many CPMs does my computer have?

$ grep processor /proc/cpuinfo | wc -l

12. View Free Memory

$ cat /proc/meminfo | grep MemFree
$ free -m

13. View active processes

$ ps -ef
$ ps aux
$ vmstat 5 10

14. Create directory tree (tree)

$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'

15. Output Asterisk PBX Applications

$ asterisk -rx "show applications" | awk '{print $1}' | sed -n -e "s/:"//p

16. Number of MTA emails identified by SPAM

$ cat /var/log/maillog | egrep -c '(Alert\!)|(identified spam)|(reject\:)'

17. How long does the computer run

$ uptime

18. Set time and date

$ date -s "Dec 12 18:30:00 2014"

19. Who am I and the effective user ID, UID and GID output

$ whoami
$ id

20. Output list of most recently logged in users

$ last -a