RDP

Intro

Remote desktop protocol (RDP) is a secure network communications protocol designed for remote management, as well as for remote access to virtual desktops, applications and an RDP terminal server.
RDP allows network administrators to remotely diagnose and resolve problems individual subscribers encounter. RDP is available for most versions of the Windows, MacOS or as an open source.
Noteworthy properties of RDP include encryption, smart card authentication, bandwidth reduction, resource sharing, the ability to use multiple displays and the ability to disconnect temporarily without logging off. RDP also allows for the redirection of functions such as audio and printing.
RDP can support up to 64,000 independent channels for data transmission. Data can be encrypted using 128-bit keys, and the bandwidth reduction feature optimizes the data transfer rate in low-speed connections.
The RDP protocol is designed to provide remote access through port 3389. An RDP-enabled application or service packages the data that is to be transmitted, and the Microsoft Communications Service directs the data to an RDP channel. From there, the operating system encrypts the RDP data and adds it to a frame so that it can be transmitted.
The Terminal Server Device Redirector Driver handles all RDP protocol activity. This driver is made up of subcomponents such as the RDP driver (Wdtshare.sys), which handles user interfaces, transfers, encryption, compression and framing. The transport driver (Tdtcp.sys) is responsible for packaging the protocol in such a way that allows it to be sent across a TCP/IP network.

See latest versions in use at https://en.wikipedia.org/wiki/Remote_Desktop_Protocol

The Remote Window Isn’t the Correct Size

Incorrect window size is another common Remote Desktop Connection issue. When you create the remote desktop connection, the window is too large, too small, or doesn’t correlate to the settings you input.
You have two potential fixes here.
First, you can force the Remote Desktop connection to use a specific size via the Run function. Hit Windows key + R, then input:

mstsc.exe /h:X /w:X

Where “X” is the height and width of the Remote Desktop viewing window you desire. Remote Desktop will remember your settings for future remote viewing settings.
The Remote Desktop Connection client has a handy screen resolution slider that scrolls from 640×480 up to Full Screen for your screen. Make sure to set the slider to Full Screen if you want a full-screen remote connection for each connection.

How to Save Your Remote Desktop Connection Custom Settings

If you regularly connect to several different servers or clients, saving a custom configuration for each Remote Desktop will save time in the future. You can set the optimum width, height, and color settings for each server or terminal.
Open the Remote Desktop Connection dialog, then select Show Options. You will now see the Connection settings options. Select Save As, specify your save location, then select Save to create a custom Remote Desktop Connection file (.RDP).
Now, browse to the Remote Desktop Connection configuration file. You can edit the configuration file using a text editor, such as Notepad or Notepad++. Right-click the configuration file and select Open with…, then select your text editor.
The first four lines show your remote connection screen size options (plus whether multi-monitor mode is available). You can edit the screen mode to set whether the remote window session appears full screen. For instance, “id:i:2” sets full screen, whereas “id:i:1” sets the remote connection to appear in a window.
If you set the screen mode to “2” for full screen, the desktopwidth and desktopheight automatically match the screen size of the host client. However, if you are using screen mode “1,” you can use the desktopwidth and desktopheight settings to set a specific window size.
After you confirm your settings, add the following string to the end of the file:

smart sizing:i:1

Smart sizing allows you to dynamically alter your screen settings without messing around with configuration files while the Remote Desktop connection is active. However, you must add the string for each custom configuration you create.

Handy Remote Desktop Connection Shortcuts

You can boost your Remote Desktop Connection productivity using a handful of keyboard shortcuts. These shortcuts are designed to work when you access Remote Desktop using the Run dialog.

  • Start Remote Desktop in full-screen mode: mstsc /f
  • Start Remote Desktop in Admin Mode: mstsc /admin
  • Matches your Remote Desktop session with the local virtual desktop: mstsc /span
  • Matches your Remote Desktop session to the Client Layout: mstsc /multimon
  • Open the .RDP file for editing—change “connection file” to your file name before running the command: mstsc /edit “connection file”

You can use the following Remote Desktop shortcuts once your Remote Desktop connection is live:

  • Switches your Remote Desktop client between full-screen and windowed mode: Ctrl + Alt + Pause
  • Force the Remote Desktop into full-screen mode: Ctrl + Alt + Break
  • Takes a screenshot of the active Remote Desktop window: Ctrl + Alt + Minus
  • Takes a screenshot of the entire Remote Desktop: Ctrl + Alt + Plus
  • Reboots the remote computer: Ctrl + Alt + End

Ubuntu server RDP – option 1 – xrdp

Access via SSH and install XRDP

sudo apt install xrdp

Follow this with

sudo systemctl enable xrdp

Ubuntu server RDP – option 2 – vnc

Another option with full remote desktop functionality is VNC. This requires a client application on the Windows PC and a server on Ubuntu.
On the remote PC, install the TightVNC Server component after checking for updates:

sudo apt update

Then install the server utility:

sudo apt install tightvncserver

You’ll then need to run it:

sudo tightvncserver

At this point you’ll be prompted to set a password for the connection. You’ll also be given a desktop number, usually :1. Keep a note of this.

Now that TightVNC Server is set up on Ubuntu, you’ll need to install the client on Windows. This can be downloaded from www.tightvnc.com/download.php—make sure you choose the right version, as it is available in 32-bit and 64-bit flavors.

TightVNC tools are only available as a bundle, so once installed, look for TightVNC Viewer in Windows search.

Once you’ve launched the viewer, input the IP address of the Ubuntu box in Remote Host, followed by the desktop number. So, it might look like this:

192.168.0.99:1

Input the password when prompted and commence your remote desktop activity!

TightVNC can be set More Secure – By default, TightVNC will encrypt your password, but nothing else. This makes it insecure for connections over the internet. Fortunately, it can be made more secure, thanks to SSH and Xming.
To use this, download and install the Xming tool for Windows from Sourceforge. Once this is done, look for the desktop shortcut, right-click, and choose Properties.
Click Apply to save the change, then OK. Double-click the icon to run Xming, then open PuTTY. Here, expand the menu on the left to Connection > SSH > X11.
Check Enable X11 Forwarding, then return to Session at the top of the menu.

It will be most secure of RDP over SSH or VNC over SSH (Mixing VNC with SSH) is used

MS Word Regex

MS Office has a handy Word regex search and replace. Below are listed most common regex options

Basic Regex used in Word

? and *

The two most basic wildcards are ? and *. They are essentially similar in use.
? is used to represent a single character and * represents any number of characters. On their own, these have limited use.
s?t
 will find satset,sit ,sot and any other combination of three characters beginning with ‘s‘ and ending with ‘t‘. It will also find that combination of letters with a word, thus it would locate the relevant (highlighted) part of inset etc.

@

@ is used to find re-occurrences of the previous character (if any). e.g. lo@t will find lot or lootful@ will find ful or full etc.

< >

With any of the above (or any other combination of wildcards and characters), you can use the brackets < and > to mark the start and end of a word respectively. Thus in the example used above for ‘*
<s*t> would find ‘secret‘ and ‘serpent‘, but not ‘sailing boats‘ and ‘sign over documents‘. Though again, given the use of ‘*‘, beware as it will find the block of text from a word starting with ‘s’ to the end of the next word in the document ending with ‘t‘, e.g. ‘sailing boat‘ which may not be what you had in mind.
The <> brackets can be used in pairs as above or individually as appropriate e.g. ful@>  will find ‘full‘ and the appropriate part of ‘wilful‘ but not ‘wilfully

[]

Square brackets are always used in pairs and are used to identify specific characters or ranges of characters. e.g.:
[abc] will find any of the letters abc[F] will find upper case ‘F‘;
[A-Z] will find any upper case letter; [0-9] will find any single number; [13579] will find any odd numbers; [0-9A-Za-z] will find any numbers or letters.
The characters can be any character or series of characters, including space. Characters are processed in order – lowest first. If you are uncertain which character is lower than another check with ‘Insert > Symbol’.

[!]

[!] is very similar to [ ] except in this case it finds any character not listed in the box so [!o] would find every character except “o”.
You can use ranges of characters in exactly the same was as with [ ], thus [!A-Z] will find everything except upper case letters.

You can paste any (Unicode) character – unfortunately *not* characters from decorative (Symbol) fonts) – into your search expressions. So copying the first and last characters from the Greek or cyrillic subsets into a search:
[;-ώ] would match any Greek character α β γ δ ε …
<[Ё-ґ]@> matches any cyrillic word: Вы можете помочь мне? (“Can you help me please?”)
You can type in Unicode characters with the Alt-key (make sure NumLock is on, then hold down the Alt-key and type the numbers on the numeric keyboard). Since all characters from decorative fonts (Symbol-, Wingdings-fonts …) are kept in a special code page from &HF000 to &HF0FF, you can search for them with [Alt61472-Alt61695].

{}

Curly brackets are used for counting occurrences of the previous character or expression.
{n}         This finds exactly the number ‘n’ of occurrences of the previous character
{n,}  Finds at least the number ‘n’ occurrences.
{n,m}      Finds the number of occurrences from ‘n’ to ‘m’.
Note: The above examples employ a comma as a list separator {n,m} – for languages that use alternative list separators, substitute the local separator character (often a semi-colon {n;m}) as appropriate.
Counting can be used with individual characters or more usefully with sets of characters e.g. [deno]{4} will match done, node, eden) or bracketed groups: (ts, ){3} will match ts, ts, ts, .
(Unfortunately, there is no wildcard to search for “zero or more occurrences” in Word wildcard searches; [!^13]{0,} does not work).

( )

Round brackets have no effect on the search pattern, but are used to divide the pattern into logical sequences, where you wish to re-assemble those sequences in a different order during the replace – or to replace only part of that sequence. They must be used in pairs.
The partnering backslash character is used as a replacement string in conjunction with a number to indicate which pair of brackets numbered from the left is required e.g.
(John) (Smith) replaced by \2 \1 – note the spaces in the search and replace strings –  will produce Smith John or replaced by \2 alone will give Smith.

\

If you wish to search for a character that has a special meaning in wildcard searches – the obvious example being ‘?‘. then you can do so by putting a backslash in front of it: [\?] will find the question mark character ‘?
If you wish to find the backslash itself then you need to precede that with a backslash [\\].
The following is a list of the characters that have a special meaning in wildcard searches ( [ ] { } < > ( ) – @ ? ! * \ )

NOTES

You may wish to identify a character string by means of a paragraph mark . The normal search string for this would be ^p.
^p DOES NOT WORK in wildcard search strings! It must however be used in replacement strings, but when searching, you must look for the substitute code ^13.
Wildcard searches will also not find footnote/endnote marks – substitute ^2.
A-z would be expected to reproduce all the letters between A and z i.e. both upper case and lower case letters, which it does, but it reproduces all the characters from ASCII 65 to ASCII 122, and that block also includes the characters [ ] ` ^ _ /  Use A-Za-z instead.
The question mark ? is used to find individual characters. If used with curly brackets to define a range of characters eg
#?{1,3}#
 it will behave as an asterisk and find all the characters between the hash symbols.

Word Specific Control Codes used with the search/replace tool

Code Notes
^1 In-line picture
^2 Auto referenced footnotes
^5 Annotation mark
^9 Tab
^11 New line
^12 Page or Section break
^13 Paragraph break / ‘carriage’ return
^14 Column break
^19 Opening field brace (when field braces are visible)
^21 Closing field brace (when field braces are visible)
? Question mark
^? Any single character (not valid in the Replace box)
^- Optional hyphen
^~ Non-breaking hyphen
^^ Caret character
^# Any digit
^$ Any letter
^& Contents of ‘Find What’ box (Replace box only)
^+ Em dash (not valid in the Replace box)
^= En dash (not valid in the Replace box)
^u8195 Em Space Unicode character value search (not valid in the Replace box)
^u8194 En Space Unicode character value search (not valid in the Replace box)
^a Comment (not valid in the replace box) (Word 97-2000 only)
^b Section break (not valid in the replace box)
^c Replace with Clipboard contents (Replace box only)
^d Field
^e Endnote Mark (not valid in the Replace box)
^f Footnote Mark (not valid in the Replace box)
^g Graphic (In Line Graphics Only). In Word 2007 a forward slash / also appears to find in-line graphics. This appears to be an unintentional bug.
^l New line
^m Manual Page Break
^n Column break
^t Tab
^p Paragraph Mark –
^s Non-breaking space
^w White space (space, non-breaking space, tab); not valid in the Replace box
^nnn Where “n” is an ASCII character number
^32 and ^032 will both represent a space character, but ^147 will represent ô and ^0147 will represent “
^0nnn See above (Produces ASCII on Macintosh).
^unnnn Unicode character search where “n” is a decimal number corresponding to the Unicode character value.

Examples

Example 1 – Transpose first name and surname

There are many occasions when you are presented with blocks of text or numbers etc., where the order of the text is not what you might require in the final document. Swapping the placement of forename and surname as above is one such example – and don’t forget you can add to the replacement, even when using bracketed replacements e.g. you may wish John Smith to appear as Smith, John or, more likely, you may have a column of names in a table, where you wish to exchange all the surnames with all the forenames.

John Smith to become Smith John

You could do them one at a time, but by replacing the names with wildcards, you can do the lot in one pass.
Let’s then break up the names into logical sequences that can only represent the names.
At its simplest, we have here two words – John and Smith. They can be represented by <*>[space]<*> – where [space] is a single press of the spacebar.
Add the round brackets  (<*>)[space](<*>) and replace with \2[space]\1
Run the search on the column of names and all are swapped. Run it again and they are swapped back.

Example 2 – Transposing dates

This could be the changing of UK format dates to US format dates – or vice versa.
7th August 2001 to August 7th, 2001
To give an example of how most of the wildcards could be used in one search sequence to find any UK date formatted above to its equivalent US format date, the following search pattern will do the trick:

[0-9]{1,2}[dhnrst]{2} <[AFJMNSOD]*>[0-9]{4}

Breaking it down [0-9] looks for any single digit number, but dates can have two numbers so to restrict that to two, we use the count function. We want to find dates with 1 or 2 numbers so [0-9]{1,2}

Next bit is the ordinal ‘th’ – Ordinals will be ‘st’ ‘rd’ or ‘th’ so identify those letters specifically: [dhnrst]

There will always be two letters, so restrict the count to 2: [dhnrst]{2}

Next comes the space. You can insert a space [space]

The month always begins with one of the following capital letters – AFJMNSOD. We don’t know how many letters this month has so we can use the blanket ‘*‘ to represent the rest. And we are only interested in that word so we will tie it down with <> brackets: <[AFJMNSOD]*>

There’s another space [space] followed by the year. The years here have four numbers so [0-9]{4}

Finally add the round brackets to provide a logical breakup of the sequence:
([0-9]{1,2}[dhnrst]{2})[space](<[AFJMNSOD]*>)[space]([0-9]{4})
and replace with \2[space]\1,[space]\3
to re-order the sequence.

Example 3 – Adding or removing the period in salutations (Mr or Mr.)

Assume you are parsing addresses and wish to separate the honorific from the name. American usage puts a full stop (period) at the end (“Mr.”, “Mrs.”, “Dr.”) while British usage often omits the full stop.

([DM][rs]{1,2})( )

will find Mr Mrs Dr without the stop and

\1.\2

will put one in. Or vice versa

([DM][rs]{1,2}).

will find Mr. Mrs. Dr. with the stop and

\1

will take it out.

Example 4: Duplicate paragraphs (and rows)

(*^13)\1\1 will match any sequence of three identical paragraphs.
If you replace:
(*^13)\1
with
\1
it will delete all consecutive duplicate paragraphs in the document. Repeat until nothing is found, to delete all duplicate paragraphs in the document (as long as you have sorted the text first).
To delete duplicate rows in a table (provided you have no merged cells), you can convert the table to text (Table + Convert to Text, using a tab delimiter); delete the duplicate paragraphs using the above method, then convert the text back to a table.

Example 5: Tags

\<([!\<>]@>)*\</\1
will match any well-formed XML element including start-tag and end-tag such as:

<p>some text </p>

or

<customer-name>John Smith</customer-name>

Alternative way: In the Find What box, enter the following string:
\<*>
Leave the Replace With box empty.
Place an X in the “Use Wildcards” box.
Click Replace All.


Example 6: Formatting

By building up appropriate patterns, you can search for almost any combination of characters.
Of course you can also restrict your searches by specifying some style or formatting, or add formatting for the replacement text. See Finding and replacing non-printing characters (such as paragraph marks), other special characters, and text formatting for more on this.
A nice trick if you want to apply formatting to a part (but not all) of the search text is to put in “tags” in a first replacement.
In a find/replace, you can only change the formatting of the whole find-text; so you would need to do two find-replaces to get the job done. In the first, you would “tag” the text that has to be formatted; in the second, you format them (and remove the tags).

Find what:
(something)(something else)(another string)

Replace with:
\1$$\2##\3

and then remove the tags and apply the formatting in a second replace:

Find what:
$$(*)##

Replace with:
\1 ((bold))

Imagine, for instance, that you’ve got a text file, and headings are marked up by having 3 empty paragraphs before them and an empty paragraph after.

Find what:
^13{4}([!^13]@^13)^13

Replace with:
^p<H1>\1

Then Find that: 
\<H1\>(*) 

Replace with: 
\1 ((style “Heading 1”))

This will remove the empty paragraphs and format the headings.

BEWARE:

Sometimes Word will get confused if it encounters “escaped” brackets \( or \), for example “(\\)” will match *any* character, not only a backslash
Workaround: use “([” instead.

([a-z]\() throws an error – should find an “a(“.
Workaround: Use ([a-z][\(]) instead.

Not a bug but still annoying: You have to escape any special character even if you type its code; so ^92 will have the same problems as typing the backslash.

The construction {0,} (find zero or more of the preceding item) is refused as incorrect syntax. This concept is available in Unix regular expression matching, so it’s a curious omission.

You don’t always have to “escape” the special characters, if the context makes it clear that the special meaning isn’t wanted. [abc-] matches ““, and [)(] matches “)” or “(“. This may sometimes make your searches behave differently from what you expected.

More Examples – Greek

More Examples – Cyrrilic

Sources

Notepad++

INTRO – Why NPP

Notepad++ is the most popular text/source code editor. It features syntax highlighting, code folding and limited autocompletion for programming, scripting, and markup languages, but not intelligent code completion or syntax checking.
We love its speed and power, but it’s even better once you dig a little deeper.

Macros

One of the killer features for Notepad++ is the ability to automate those trivial things we have to write on a daily basis. To do this with macros, simply click the record button on the toolbar and perform the task. For example, if you wanted to delete every other character in a document, you would click right, right, then backspace. After doing this once, click the stop button to finish recording your macro. Press play each time you want this action performed, or click the fast forward button to initiate the action multiple times. You can even save a created macro for further use, by assigning it one of the many available keyboard shortcuts found under the save macro button.

Column Editing

Another interesting feature you won’t find in your everyday text editor is Column Editing. You can invoke column selection by holding down the Alt key while selecting text. From here you can cut, copy, paste, insert, and delete, just as you would with normal text selection. Furthermore, you can insert Variable Text in these column selections. By default, Notepad++ allows you to insert an initial number with an incremental value, so that you can create numbered lists on the fly.

Project Management, Tabulated

Notepad++ has the ability to save your current working state, and it also benefits from tabbed browsing. You can use this more to your advantage by creating sessions. File >> Save Session and specify a name and file extension for this project. When you’d like to bring this project up again, just select File >> Open Session and navigate to this project file. Your project files will be intact from the last time you saved them. By default Notepad++ treats your open tabs as a session, and loads that session up after restarting the application.

File Comparison

Often you may want to have two files open side-by-side rather than tabbed in one window. To split the application window, select one of the documents of interest, right click, and choose Move to Other View. If you’d like to create another version of the same file, select Clone to Other View. On a related note, you can also compare the contents of the last two tabs open using Compare from the plugins menu. This can be useful for code revisions or rewrites in general. Furthermore, with Compare you can even compare your current file with the previous save by selecting Compare to Last Save

Custom Highlighting and Tweak

The programming language detection is automatic, but you can change it if necessary through the languages menu. If the language you require is not included by default, check online for over 50 additional options and instructions for installation

Plugins

Extensive list of plugins to do anything one wishes.
Examples:
QuickText – Here we will define hotstrings to be replaced with user-defined text.
Compare – compare two notes side-by-side. This can be useful for code revisions or rewrites in general. Furthermore, with Compare you can even compare your current file with the previous save by selecting Compare to Last Save, or just pressing Alt+S
Autosave – it should be the first plugin you set up (it’s included with install, so you have no excuse). You can choose to save all open tabs, or the current one on a timed interval, or simply when Notepad++ loses focus.

Styling

Under Settings on the Menu bar. From here you can select an included theme, but you certainly aren’t limited to these. You may define your own globally, or limit it to specific languages. You can also change the default font from here (which I usually do, as Courier New’s 1’s tend to look an awful lot like lowercase L’s). You can do a little bit more tweaking from the Preferences menu, also found under Settings. From here, you can check the Vertical checkbox to load the tabs on the side. You can also choose to hide the menu bar, revealing it with the Alt key.
New theme cam be created at C:\Users\user_name\AppData\Roaming\Notepad++\themes

Configs

Recently opened files quickly

You can get up to 15 files in the list with the actual path. If you think that this feature is useful, and you want to increase the number of “Recently Opened” files, here is a trick to increase or decrease the number. Open Settings > Preferences. Under the Recent Files History, you will get the option to change the number.

Workspace and Treeview

If you are developing a theme, obviously there are more than one files. It is quite difficult to open and close different files in a particular folder. To solve this problem, Notepad++ has an awesome feature called Folder as Workspace, which helps users to view all the files and folders in the tree view. You can see a sidebar on the left-hand side that will let you open a particular folder and file. To open a folder, click on File > Open Folder as Workspace

Tasks and Functions

Find text and replace in multiple files

Select Search > Find in Files from the menu. If you like keyboard shortcuts better, use Ctrl-Shift-F to open the search window instead. The find in files configuration window is pretty easy to use as you can ignore most options if you don’t require them. You can also use regex and the replace option to replace the text you entered with other text.

Find changes side by side

If you have made few changes in a particular file or say you want to make two instances of a single file. To do this, open or create the file that you want to place side by side or make another instance. Then, right-click on the tab and select Clone to Other View.
Any two files can be compared with the COMPARE plugin also.

Box selection

Box selection means that text can be selected vertically as well as horisontally. Really cool. You need to hold down the Alt key while doing a selection; you can select a block horizontally.

Run in browser

You can test html file in browser by clicking RUN and select Launch in Browser.

Align Lines

It’s my favorite feature. You can line up multiple lines by ,(comma), = (equal sign) or clipboard character. It is very useful and helpful in Box selection. (needs TextFX plugin)

Handy RegEx

[ ] – The square brackets can be used to match ONE of multiple characters. For instance, [abc] matches any of the characters a, b or c. Ranges can also be used, [a-z]

^ – The caret can be used inside the square brackets to exclude characters from the match. For instance, hell[^o] means the string ‘hell’ will be ignored if followed by the letter ‘o’. Another example is [^A-Za-z] which will exclude all alphabetic characters.

$ – This matches the end of a line.

. – The period or dot matches any character.

\d – Matches any single digit.

\w – Matches any single alphanumeric characters or underscore.

\s – Matches whitespaces including tabs and line breaks.

* – The asterisk or star sign matches 0 or more times. For example, Ba*m matches Bm , Bam , Baam etc.

+ – The plus sign matches 1 or more times. For example, lo+l matches lol , lool , loool etc.

\< – Matches the start of a word. For example, \< directly followed by ‘sh’ matches ‘she’ but does not matches ‘wish’.

\> – Matches the end of a word. For example, sh\> matches ‘wish’ and does not matches ‘she’.

( ) – The round brackets can be used in the Find & Replace function to tag a match. tagged matches can then be used in replace with \1, \2 etc. For example, If you write 123xxxRRR in the search and 123\1HHH in the ‘Replace with’ filed, the result will be: 123xxxHHH.

\ – The backslash can be used to escape regex characters. For example to match 1+1=2, the correct regex is 1\+1=2. Otherwise, the plus sign will have a special meaning.

Search for number of digits and add a dot at the end:
Find: (\d\d)
Replace: \1.

Remove a dot at te end of any line:
Find: [.]\r
Replace: leave blank

SSH logins and keypairs

Secure Shell (SSH) is a UNIX-based command interface and protocol for securely getting access to a remote computer. SSH is actually a suite of three utilities – slogin, ssh, and scp – that are secure versions of the earlier UNIX utilities, rlogin, rsh, and rcp. SSH commands are encrypted and secure in several ways. Both ends of the client/server connection are authenticated using a digital certificate, and passwords are protected by being encrypted.SSH allows you to connect to your server securely and perform Linux command-line operations.
There are multiple reasons why SSH fails. Here’s a list with most of the common cases:

  • The server might not be configured to accept public key authentication. Make sure /etc/ssh/sshd_config on the server contains line PubkeyAuthentication yes. Remember to restart the sshd process on the server. Use service sshd restart or systemctl restart network
  • If trying to login as root, the server might not be configured to allow root logins. Make sure /etc/sshd_config includes PermitRootLogin yes, PermitRootLogin prohibit-password, or without-password. If it is set to forced-commands-only, the key must be manually configured to use a forced command (see command= option in ~/.ssh/authorized_keys.
  • Make sure the client allows public key authentication. Check that /etc/ssh/config includes PubkeyAuthentication yes.
  • Try adding -v option to the ssh command used for the test. Read the output to see what it says about whether the key is tried and what authentication methods the server is willing to accept.
  • OpenSSH only allows a maximum of five keys to be tried authomatically. If you have more keys, you must specify which key to use using the -i option to ssh.
  • in messages log information about bad ownership of authorized_keys. Changed permissions for my /home/USERNAME/.ssh/authorized_keys to 0600 and that should fix it.
  • opened authorized_keys in vi and remove all of the line breaks – that could also help
    Finally restart service: /etc/init.d/ssh restart or service sshd restart or systemctl restart network
  • At the end The whole purpose of authenticating via key file is to avoid password authentication, so actually you should reverse PasswordAuthentication to no
  • NOTE: You copy the key out of the PuTTYGen window instead of saving the file, but after copying, the way you paste may have significant impact on whether your key will work or not. Some editors will alter the text as you paste, or do something with newlines or something that makes the authorized_keys file invalid.
    It’s strongly advisable to use Notepad++ for such sensitive cases
  • Also the right type of key for Putty is using ppk file instead of pem. If public key is created with PuttyGen it creates a bloated key with unnecessary lines. Please strip it down to a single line ssh-rsa AAAAB…

From

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20121022"
AAAAB3NzaC1yc2EAAAABJQAAA
a6N1nFpBklz1+dsIMg4rcTLc
tr7mmimiTjkoSCrJh1kqalPS
---- END SSH2 PUBLIC KEY ----

To:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAhGF6GIuMY8FJ1+CNApnSY1N2YSlkYz72Yvwua6N1nFpBklz1+dsIMg4rcTLcF34M/tW5Yz+NUDAw2AEbxQ32FPgw7sAOIXktkYOHtr7mmimiTjkoSCrJh1kqalPSpi8rglT/Bp67Ql2SZwvUFfMzHISryR0EZC4rXP/uvObrJe8= rsa-key-20190901

Ways to import Keys into server

ssh-copy-id installs an SSH key on a server as an authorized key. Its purpose is to provision access without requiring a password for each login. This facilitates automated, passwordless logins and single sign-on using the SSH protocol.
The ssh-copy-id tool is part of OpenSSH.
An SSH key is created using ssh-keygen. In the simplest form, just run ssh-keygen and answer the questions. The following example illustates this

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/me/.ssh/id_rsa): mykey
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in mykey.
Your public key has been saved in mykey.pub.
The key fingerprint is:
SHA256:GKW7yzA1J1qkr1Cr9MhUwAbHbF2NrIPEgZXeOUOz3Us root@localhost
The key's randomart image is:
+---[RSA 2048]----+
|.*++ o.o.        |
|.+B + o.        |
| +++ *+.         |
| .o.Oo.+E        |
|    ++B.S.       |
| o * =.          |
|  + = o          |
| + = =   .       |
|  + o o          |
+----[SHA256]-----+
#

When you have an SSH key you need the public key to setup SSH passwordless login with SSH-key. But if you have lost the public key part but still have the private key, there is a way to regenerate the key.
With the public key missing, the following command will show you that there is no public key for this SSH key.

$ ssh-keygen -l -f ~/.ssh/id_rsa
test is not a public key file.

The -l option instructs to show the fingerprint in the public key while the -f option specifies the file of the key to list the fingerprint for.
To generate the missing public key again from the private key, the following command will generate the public key of the private key provided with the -f option.

$ ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
 Enter passphrase:

The -y option will read a private SSH key file and prints an SSH public key to stdout. The public key part is redirected to the file with the same name as the private key but with the .pub file extension. If the key has a password set, the password will be required to generate the public key.
To check the details of the generated public key execute the following command as shown above.

$ ssh-keygen -l -f ~/.ssh/id_rsa
 4096 d6:7b:c7:7a:4f:3c:4d:29:54:62:5f:2c:58:b2:cb:86 ~/.ssh/id_rsa (RSA)

The output of this command shows the key size as the first column, the fingerprint as the second column and after the file name, the type is shown in brackets. In the example above, a 4096 bit RSA key.

The key files are usually stored in the ~/.ssh directory. You should never save the file with its contents starting with —–BEGIN RSA PRIVATE KEY—– on the server, that is your private key. Instead, you must put the public key into the ~/.ssh/authorized_keys file. This public key has the .pub extension when generated using ssh-keygen and its contents begin with ssh-rsa AAAAB3…
The permissions of~/.ssh on the server should be 700. The file ~/.ssh/authorized_keys (on the server) is supposed to have a mode of 600. The permissions of the (private) key on the client-side should be 600.
If the private key is not deleted you can generate the public key from the private key at any time. You can do this simply with the following command:

ssh-keygen -y -f key.pem > key.pub 

Once the key has been copied, it is best to test it: ssh -i ~/.ssh/mykey user@host

Best practices for SSH keys

  • SSH keys are very useful, but can lead to problems if they are not properly managed. They are access credentials just like user names and passwords. If they are not properly removed when people leave or systems are decommissioned, no-one may any longer know who really has access to which systems and data. Many large organizations have ended up having millions of SSH keys.

    Use a passphrase when possible
  • It is recommended that keys used for single sign-on have a passphrase to prevent use of the key if it is stolen or inadvertatly leaked. The ssh-agent and ssh-add programs can be used to avoid having to enter the passphrase every time the key is used. Generally all keys used for interactive access should have a passphrase. Keys without a passphrase are useful for fully automated processes. They allow shell scripts, programs, and management tools to log into servers unattended. This is often used for backups and data transfers between information systems.

    Add a command restriction when possible
  • The copy-id tool does not automatically add command restrictions to keys. Using command restrictions is highly recommended when the key is used for automating operations, such as running a report for fetching some files. A command restriction is basically a command=”” option added to the beginning of the line in the server’s authorized_keys file.

    Managing SSH keys
  • Anyone having more than a few dozen servers is strongly recommended to manage SSH keys. Not managing the keys exposes the organization to substantial risks, including loss of confidentiality, insertion of fraudulent transactions, and outright destruction of systems.


Mega

Mega.nz is a Secure Cloud Storage and Communication. Privacy by Design. Create a MEGA account to get 50 GB FREE storage (reduced to 15GB in 30 days)

  • Reliable Storage and Fast Transfers
  • End-to-End Encryption
  • Secure Communication
  • The Secure Solution for Your Business
    • Personal Account From 4.99 € / month
    • Business Account From 10.00 € / user / month (min of 3 users)
  • Open Source
  • File Versioning
  • File backup
  • Extensions (FF/Chrome)
  • MEGAdrop
  • MEGAbird
  • MEGAcmd – Commandline, Scriptable, Autobackup, WebDav, FTP
  • MEGAcmd – Command Line Interactive and Scriptable Application – https://github.com/meganz/MEGAcmd/
  • MEGAcmd User Guide – https://github.com/meganz/MEGAcmd/blob/master/UserGuide.md

Mega Plans

FREE$0.0050 GB10 GB/Month on DL
LITE€4.99/month – €49.99/year200 GB1 TB
PRO I€9.99/month – €99.99/year500 GB2 TB
PRO II€19.99/month – €199.99/year2 TB4 TB
PRO III€29.99/month – €299.99/year4 TB8TB

Command line summary

These summaries use the usual conventions – [] indicates its content is optional, | indicates you should choose either the item on the left or the one on the right (but not both)

Each command is described as it would be used in the interactive MEGAcmd shell, and the corresponding scriptable command (which must be prefixed with mega-) works in the same way.

Commands referring to a remote path are talking about a file in your MEGA account online, whereas a local path refers to a file or folder on your local device where MEGAcmd is running.

Verbosity: You can increase the amount of information given by any command by passing -v (-vv, -vvv, …)

Account / Contacts

  • signupemail [password] [--name="Your Name"] Register as user with a given email.
  • confirmlink email [password] Confirm an account using the link provided after the “signup” process.
  • invite[-d|-r] dstemail [--message="MESSAGE"] Invites a contact / deletes an invitation.
  • showpcr[--in | --out] Shows incoming and outgoing contact requests.
  • ipcemail|handle -a|-d|-i Manages contact incoming invitations.
  • users[-s] [-h] [-n] [-d contact@email] List contacts
  • userattr[-s attribute value|attribute] [--user=user@email] Lists/updates user attributes
  • passwd[oldpassword newpassword] Modifies user password
  • masterkeypathtosave Shows your master key.

Login / Logout

  • login[email [password]] | exportedfolderurl#key | session Logs into MEGA
  • logout[--keep-session] Logs out
  • whoami[-l] Print info of the user
  • session Prints (secret) session ID
  • killsession[-a|sessionid] Kills a session of current user.

Browse

  • cd[remotepath] Changes the current remote folder
  • lcd[localpath] Changes the current local folder for the interactive console
  • ls[-lRr] [remotepath] Lists files in a remote path
  • pwd Prints the current remote folder
  • lpwd Prints the current local folder for the interactive console
  • attrremotepath [-s attribute value|-d attribute] Lists/updates node attributes
  • du[-h] [remotepath remotepath2 remotepath3 ... ] Prints size used by files/folders
  • find[remotepath] [-l] [--pattern=PATTERN] [--mtime=TIMECONSTRAIN] [--size=SIZECONSTRAIN] Find nodes matching a pattern
  • mount Lists all the main nodes

Moving/Copying Files

  • mkdir[-p] remotepath Creates a directory or a directory hierarchy
  • cpsrcremotepath dstremotepath|dstemail Copies a file/folder into a new location (all remotes)
  • put[-c] [-q] [--ignore-quota-warn] localfile [localfile2 localfile3 ...] [dstremotepath] Uploads files/folders to a remote folder
  • get[-m] [-q] [--ignore-quota-warn] exportedlink#key|remotepath [localpath] Downloads a remote file/folder or a public link
  • preview[-s] remotepath localpath To download/upload the preview of a file.
  • thumbnail[-s] remotepath localpath To download/upload the thumbnail of a file.
  • mvsrcremotepath [srcremotepath2 srcremotepath3 ..] dstremotepath Moves file(s)/folder(s) into a new location (all remotes)
  • rm[-r] [-f] remotepath Deletes a remote file/folder
  • transfers[-c TAG|-a] | [-r TAG|-a] | [-p TAG|-a] [--only-downloads | --only-uploads] [SHOWOPTIONS] List or operate with transfers
  • speedlimit[-u|-d] [-h] [NEWLIMIT] Displays/modifies upload/download rate limits
  • sync[localpath dstremotepath| [-dsr] [ID|localpath] Controls synchronizations
  • exclude[(-a|-d) pattern1 pattern2 pattern3 [--restart-syncs]] Manages exclusions in syncs.
  • backuplocalpath remotepath --period="PERIODSTRING" --num-backups=N Set up a new backup folder and/or schedule
  • backup[-lhda] [TAG|localpath] [--period="PERIODSTRING"] [--num-backups=N]) View/Modify an existing backup schedule

Sharing (your own files, of course, without infringing any copyright)

  • cpsrcremotepath dstremotepath|dstemail Moves a file/folder into a new location (all remotes)
  • export[-d|-a [--expire=TIMEDELAY]] [remotepath] Prints/Modifies the status of current exports
  • importexportedfilelink#key [remotepath] Imports the contents of a remote link into your account
  • share[-p] [-d|-a --with=user@email.com [--level=LEVEL]] [remotepath] Prints/Modifies the status of current shares
  • webdav[ [-d] remotepath [--port=PORT] [--public] [--tls --certificate=/path/to/certificate.pem --key=/path/to/certificate.key]] Sets up the ability to download a file from your MEGA account via your PC/device.

Misc

  • version[-l][-c] Prints MEGAcmd versioning and extra info
  • deleteversions [-f] (--all | remotepath1 remotepath2 ...) Delete prior versions of files to save space.
  • unicode Toggle unicode input enabled/disabled in interactive shell
  • reload Forces a reload of the remote files of the user
  • help[-f] Prints list of commands
  • https[on|off] Shows if HTTPS is used for transfers. Use https on to enable it.
  • clear Clear screen
  • log[-sc] level Prints/Modifies the current logs level
  • debug Enters debugging mode (HIGHLY VERBOSE)
  • exit|quit [--only-shell] Quits MEGAcmd

AWS basics

Intro

A great calculator for the services used can be found at https://calculator.s3.amazonaws.com/index.html
Amazon is most famous with the virtual server it provides (EC2). However many more managed services are provided on top of it

Servers

Aws virtual servers are called instances – EC2. Computing unit EC2 needs storage utilized by EBS volumes. EBS volumes also come with snapshot capabilities. An EBS snapshot is a point-in-time copy of an EBS volume, meaning that it stores the exact image of an EBS volume at a certain point-in-time.
EBS snapshots are, in fact, stored by default in Amazon S3, but in a separate AWS infrastructure that is not a user-visible bucket. We’ll touch on this more a bit later. If you are already managing workloads on AWS, you certainly know that AWS storage bills can get quite high.

  • The cost of EBS snapshots is $0.05 per GB per month.
  • S3 storage is in average $0.022 per GB per month

Backups

There are two ways to implement backups of your EC2 instances on AWS:

  • If your instance is EBS-backed, you can create the snapshots of the EBS volume.
  • Or, you can create an AMI of your instances as a backup solution.

Both the EBS snapshot and the AMI are automatically stored on Amazon S3 which is known for being highly durable and reliable. That is already designed to use as little storage space as possible! Incrimental snapshots explained here.
In 2019 AWS introduced it’s own AWS Backup. It is set up and managed through an AWS Management Console through which users can configure and audit the AWS resources they backup, automate backup scheduling, set retention policies, and monitor recent backups and restores in one place.

Sample prices for the US East region are below:

 AWS ServiceWarm $/month (S3)Cold $/month (Glacier)
BackupEFS0.050.01/GB
 EBS0.05n/a
 RDS Database 0.095n/a
 DynamoDB Table0.10n/a
 Storage Gateway0.05n/a
RestoreEFS0.02/GB0.03/GB
 EBSFreen/a
 RDS DatabaseFreen/a
 DynamoDB Table0.05/GBn/a
 Storage GatewayFreen/a

S3 storage

Simple Storage Solution (S3) – Amazon S3 has a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. Works perfect for Cloud backup with enhanced permission scheme, making it a little more confusing than other cloud backup solutions. It has advanced IAM The cheaper , cold version of storage – Glacier has limits on retrieavel in standart mode (see below)

AWS Glacier

Glacier is AWS cold storage, few times cheaper than S3. There is no native way to move Snapshots to Glacier. EBS snapshots are stored in S3, but that is a “behind the scenes” implementation detail. The snapshots are not visible in an S3 bucket, not are they exposed via the S3 API. So you cannot move them to Glacier.

  • Expedited — Expedited retrievals allow you to quickly access your data when occasional urgent requests for a subset of archives are required. Expedited retrievals are typically made available within 1–5 minutes. Provisioned Capacity ensures that retrieval capacity for Expedited retrievals is available when you need it. For more information, see Provisioned Capacity.
  • Standard — Standard retrievals allow you to access any of your archives within several hours. Standard retrievals typically complete within 3–5 hours. This is the default option for retrieval requests.
  • Bulk — Bulk retrievals are Glacier’s lowest-cost retrieval option, which you can use to retrieve large amounts, even petabytes, of data inexpensively in a day. Bulk retrievals typically complete within 5–12 hours.

S3 Glacier archives have a minimum 90 days of storage, and archives deleted before 90 days incur a pro-rated charge equal to the storage charge for the remaining days.
Free Tier Only Policy for Retrieval: You can set a data retrieval policy to Free Tier Only to ensure that your retrievals will always stay within your free tier allowance, so you don’t incur data retrieval charges. If a retrieval request is rejected, you will receive an error message stating that the request has been denied by the current data retrieval policy.
Max Retrieval Rate can be set to say 1GB/hr which will cost $0.01 per GB. That comes up to $7.20 per month or less (730hrs in a month)
If extended to say 10GB/hr, each GB per hr retrieved will be charged per that predefined charge per Gig.
With both Free Tier Only and Max Retrieval Rate policies, data retrieval requests that would exceed the retrieval limits you specified will not be accepted.

IAM – AWS Identity and Access Management

AWS Identity and Access Management (IAM) enables you to manage access to AWS services and resources securely. Using IAM, you can create and manage AWS users and groups, and use permissions to allow and deny their access to AWS resources.  Offered as part of the service with no additional costs.

Best practices include the following:

  • Lock Away Your AWS Account Root User Access Keys
  • Create Individual IAM Users
  • Use Groups to Assign Permissions to IAM Users
  • Grant Least Privilege
  • Get Started Using Permissions with AWS Managed Policies
  • Use Customer Managed Policies Instead of Inline Policies
  • Use Access Levels to Review IAM Permissions
  • Configure a Strong Password Policy for Your Users
  • Enable MFA
  • Use Roles for Applications That Run on Amazon EC2 Instances
  • Use Roles to Delegate Permissions
  • Do Not Share Access Keys
  • Rotate Credentials Regularly
  • Remove Unnecessary Credentials
  • Use Policy Conditions for Extra Security
  • Monitor Activity in Your AWS Account

AWS VPC

Amazon VPC is the networking layer for Amazon EC2 . Complete details here

  • VPCs are based on Subnets Private subnets with no Public IPs and Public subnets open to Internet via Elastic IP (EIP) or a Network Gateway
  • Supported Platforms
  • Default and Nondefault VPCs
  • Accessing the Internet – Gateway (for whole subnet) or Public IP (per instance) is required for acces of external resources
  • Accessing a Corporate or Home Network – IPSec vpn or DirectConnect
  • Accessing Services Through AWS PrivateLink
  • AWS Private Global Network Considerations

Route 53 – DNS

Advanced DNS with aliaces and internal redirect, too good. Uses CNAMEs and ANAMEs !!

RDS – MS SQL, PostgreSQL, MongoDB, Aurora

CloudWatch

alerting rules along with SNS – simple notification ans SES – simple email notifications

CloudFront – managed CDN

WorkSpaces – Workstations in the cloud

AWS support

help support plans – Developer/Business/Enterprise

AWS

Ten Commandmends

The Ten Commandments of IT Slackerism

1. Stupidity is not the same as the lack of intelligence… It’s an independent dimension, quality of its own. It’s unwitting self-destruction, the ability to act against one’s best interests, social blindness…  It’s a a typical quality of gifted programmers/system administrators and you need to cultivate skepticism and your sense of humor in order to fight this disease before it destroys you…

 2·There is a very fine line between software development as job, as hobby, and as mental disease. Thou shalt cultivate other interests to ensure that evil software development spirits do not fully possess thy soul.  There’s much more to life than developing software day and night including open source software. Remember about warning signs of a software developer addiction: “My personal appearance went downhill. I didn’t care. My girlfriend left. I lost my job. I didn’t care. I had become, yes, a open source programmer!”.  Remember that sacrificing your life for developing some semi-useless and duplicative open source program might be not the best way to realize yourself as a person. Developers pay for OSS, and they often pay a heavy price. Just ask Larry Wall.

  3. Value your time and use the highest level of language possible. Program in scripting language unless it is absolutely necessary to use compiled language or Java.  If your program does not work or is useless it is not important how efficient it is. If it is useful,  people will use it even it is slightly slower then compiled language version. Also, typically 20% of code consumes 80% of time, therefore concentrating on those you can speed the program much more that writing everything in lower level language.

Ignore the proliferation of OO programming languages (all of which seem to have stolen countless features from one another). It makes it difficult to understand why all those features are needed, and, especially, why the hell you should study them.  That’s not a warning sign that you cannot cope with the University program. That actually may means two things:

  • You are still normal despite studying software engineering for some time.
  • In software fashion rulez no matter what.

4. Thou shalt know by your heart that all software sucks, but Unix sucks less the other OSes. Beware of those who say that their software does not suck, for they are either zealots or liars or charlatans. There is no silver bullet in software engineering.  That includes Microsoft products, GCC, Linux, Solaris, Java, etc.  Most of the books/articles that worship some fashionable trends that promise some kind of breakthrough are either intentionally (written by software engineering charlatans)  or unintentionally ( written by religious zealots) misleading and will be forgotten in a decade or so.

The only true revelation of the art of programming is contained in  O’Reilly’s IT manuals. In operating systems domain Unix is more elegant and sucks less that other OSes, but it still sucks. Especially as a desktop. The necessity to tinker with OS to make some device work is a good training exercise during college days, but it became annoying and distracting masochism  later. Both Microsoft Windows and Linux are to operating systems what McDonalds is to gourmet cooking: too much fat.  Thou shalt try other OSes including minimized Linux distributions, OpenBSD/FreeBSD, etc, it is has features that make it more suitable to the task in hand. Never assume that any particular OS is good for all tasks.

5. When people are free to do as they please, they usually imitate each other. It’s better to destroy your health while you are being handsomely paid, that do it for free.Paradoxically a lot of great software was written by trying to meet tough deadlines in the commercial project.

6. Beware of “this needs to be rewritten” trap. More often that not this is just a manifestation of  “Not invented here” syndrome, which is a powerful motivator for doing stupid things. I’ve never seen an good programmer who examined the code and did not say or think “Well, this crap needs to be rewritten!” If code works, it usually doesn’t need to be rewritten despite the fact that it doesn’t fit your prejudices. Value your time and don’t rewrite things that does not make sense in any language… unless absolutely necessary

 7. When you encounter ideas pushed by higher management that politely could only be described as “ridiculous” think twice before trying to enlighten those poor smacks. The chances are reasonably high that the “the one, the only” whom you try to enlighten is a sociopath and you will inflict severe punishment on yourself for your own stupidity.  Instead of boiling about stupidity of the idea, think about (possibly covert) ways to convert completely stupid suggestion into something at least workable without irritating stupid jerks. Or at least benefiting personally from this stupidity.  Moreover in ten years differences much be negligible as everything will be swiped in the sea of obsolesce  by a new wave of technologies.
IT management jerks control much less that they think and circumventing them helps to polish your architectural skills ;-).  Think strategically and try to understand simple fact that in 3-5-10 years nobody will care about the fact that those jerks moved electrons in wrong direction. It’s all like creating a beautiful painting on a sand beach — the next big wave will wipe everything anyway. Chances are that during the project you might have an opportunity to change the direction in some kind of covert action; also think about what you can learn while doing the project independently of the results and what training you can get  as a bonus for not questioning stupid higher up judgment.

8. Initiative in any large corporation IT department is a punishable offence. You will be much better off writing open source software as a hobby under pseudonym, or taking a couple of courses at company expense, then trying to break the bureaucracy walls in your current company. Actually self-education including but not limited to writing open source software might get you faster to better position, salary, etc in a different company that might value your skills higher then current.

9. Remember that in any project the most suitable programming language is the language that project leader knows the best.  Don’t fight such idiosyncrasies even if you hate the language. You can always generate one language from another and create a prototype in the language you like (without advertizing this transgression 😉 and manually translate it into a target language. Think strategically: the language is just one tool in the tool chain and if it has a good debugger  it’s an OK language. Otherwise try to find other people who share your resentment and present facts about debugger quality in an objective non-threatening to the ego of the project leader way.

10. Thou shall never believe that by clapping hands and chanting “La! La! La! Free/Open Software is the best!” long and loudly enough, it’ll come true. That’s Raymondism. Choose free over non-free only when it is better suits your needs or you have no money to buy commercial software and thou art willing to fix what is broken. Choose a license of thine liking for software thou writest and do not blame those who choose differently for software they write. Remember that Unix is more than 30 years old, GNU is more then 25 years old, and Linux is more then 15 years old. Never refer to anything that is more then ten years old as revolutionary. You should just laugh at those poor jerks who call  Linux a “the revolutionary operating system”.  Linux is  “the last century operating system” and no better or worse then other flavors of Unix; it just more bloated :-).  Ask yourself if it really make sense killing yourself trying make it better or promoting it in your crazy corporate IT environment. Whatever flavor of Unix is present in your environment might suit you just fine :-). Open Standards are not equivalent to open source and are more important than open source. Like people benefit from knowing more than one language, programmers can benefit from knowing and using at least two OSes: one for the desktop and the other for the server. Monoculture of software is bad, diversity within reasonable limits is good.  Never put all eggs into one basket, be it Windows or Linux, Java or Python.

and do not blame those who choose differently for software they write. Remember that Unix is more than 30 years old, GNU is more then 25 years old, and Linux is more then 15 years old. Never refer to anything that is more then ten years old as revolutionary. You should just laugh at those poor jerks who call  Linux a “the revolutionary operating system”.  Linux is  “the last century operating system” and no better or worse then other flavors of Unix; it just more bloated :-).  Ask yourself if it really make sense killing yourself trying make it better or promoting it in your crazy corporate IT environment. Whatever flavor of Unix is present in your environment might suit you just fine :-). Open Standards are not equivalent to open source and are more important than open source. Like people benefit from knowing more than one language, programmers can benefit from knowing and using at least two OSes: one for the desktop and the other for the server. Monoculture of software is bad, diversity within reasonable limits is good.  Never put all eggs into one basket, be it Windows or Linux, Java or Python.

The Ten Commandments, Short Version

Here is a short version for the time-pressed or lazy as they prefer to be known.

  1. God rules
  2. Images are copyrighted
  3. Swear in moderation
  4. Sunday double time
  5. Honor stuff
  6. Only kill what you eat or dislike
  7. Cheat not unless pushed
  8. Steal considerately
  9. Don’t lie much
  10. Ass. Don’t go there.

A Modern Version of The 10 Commandments

Compared with modern legislation, or even the small print in any contract, the 10 commandments are crystal clear.  Nevertheless, they benefit from modern treatment especially for those who, while less than fully committed to modern religious teachings, feel the 10 commandments have innate worth.

  1. You should not worry, for worry is the most unproductive of all human activities.
  2. You should not be fearful, for most of the things we fear never come to pass.
  3. You should not cross bridges before you come to them, for no one yet has succeeded in accomplishing this.
  4. You should face each problem as it comes. You can only handle one at a time anyway.
  5. You should not take problems to bed with you, for they make very poor bedfellows.
  6. You should not borrow other people’s problems. They can better care for them than you can.
  7. You should not try to relive yesterday for good or ill, it is forever gone. Concentrate on what is happening in your life and be happy now!
  8. You should be a good listener, for only when you listen do you hear ideas different from your own. It is hard to learn something new when you are talking, and
  9. some people do know more than you do.
  10. You should not become “bogged down” by frustration, for 90% of it is rooted in self-pity and will only interfere with positive action. You should count thy blessings, never overlooking the small ones, for a lot of small blessings add up to a big one.

The Ten Commandments of Computer Ethics

  1. Thou shalt not use a computer to harm other people.
    Simply put: Do not use the computer in ways that may harm other people. Explanation: This commandment says that it is unethical to use a computer to harm another user. It is not limited to physical injury. It includes harming or corrupting other users’ data or files. The commandment states that it is wrong to use a computer to steal someone’s personal information. Manipulating or destroying files of other users is ethically wrong. It is unethical to write programs, which on execution lead to stealing, copying or gaining unauthorized access to other users’ data. Being involved in practices like hacking, spamming, phishing or cyber bullying does not conform to computer ethics.
  2. Thou shalt not interfere with other people’s computer work.
    Simply put: Do not use computer technology to cause interference in other users’ work. Explanation: Computer software can be used in ways that disturb other users or disrupt their work. Viruses, for example, are programs meant to harm useful computer programs or interfere with the normal functioning of a computer. Malicious software can disrupt the functioning of computers in more ways than one. It may overload computer memory through excessive consumption of computer resources, thus slowing its functioning. It may cause a computer to function wrongly or even stop working. Using malicious software to attack a computer is unethical.
  3. Thou shalt not snoop around in other people’s computer files.
    Simply put: Do not spy on another person’s computer data. Explanation: We know it is wrong to read someone’s personal letters. On the same lines, it is wrong to read someone else’s email messages or files. Obtaining data from another person’s private files is nothing less than breaking into someone’s room. Snooping around in another person’s files or reading someone else’s personal messages is the invasion of his privacy. There are exceptions to this. For example, spying is necessary and cannot be called unethical when it is done against illegitimate use of computers. For example, intelligence agencies working on cybercrime cases need to spy on the internet activity of suspects.
  4. Thou shalt not use a computer to steal.
    Simply put: Do not use computer technology to steal information. Explanation: Stealing sensitive information or leaking confidential information is as good as robbery. It is wrong to acquire personal information of employees from an employee database or patient history from a hospital database or other such information that is meant to be confidential. Similarly, breaking into a bank account to collect information about the account or account holder is wrong. Illegal electronic transfer of funds is a type of fraud. With the use of technology, stealing of information is much easier. Computers can be used to store stolen information.
  5. Thou shalt not use a computer to bear false witness.
    Simply put: Do not contribute to the spread of misinformation using computer technology. Explanation: Spread of information has become viral today, because of the Internet. This also means that false news or rumors can spread speedily through social networking sites or emails. Being involved in the circulation of incorrect information is unethical. Mails and pop-ups are commonly used to spread the wrong information or give false alerts with the only intent of selling products. Mails from untrusted sources advertising certain products or spreading some hard-to-believe information, are not uncommon. Direct or indirect involvement in the circulation of false information is ethically wrong. Giving wrong information can hurt other parties or organizations that are affected by that particular theme.
  6. Thou shalt not copy or use proprietary software for which you have not paid (without permission).
    Simply put: Refrain from copying software or buying pirated copies. Pay for software unless it is free. Explanation: Like any other artistic or literary work, software is copyrighted. A piece of code is the original work of the individual who created it. It is copyrighted in his/her name. In case of a developer writing software for the organization she works for, the organization holds the copyright for it. Copyright holds true unless its creators announce it is not. Obtaining illegal copies of copyrighted software is unethical and also encourages others to make copies illegally.
  7. Thou shalt not use other people’s computer resources without authorization or proper compensation.
    Simply put: Do not use someone else’s computer resources unless authorized to. Explanation: Multi-user systems have user specific passwords. Breaking into some other user’s password, thus intruding his/her private space is unethical. It is not ethical to hack passwords for gaining unauthorized access to a password-protected computer system. Accessing data that you are not authorized to access or gaining access to another user’s computer without her permission is not ethical.
  8. Thou shalt not appropriate other people’s intellectual output.
    Simply put: It is wrong to claim ownership on a work which is the output of someone else’s intellect. Explanation: Programs developed by a software developer are her property. If he is working with an organization, they are the organization’s property. Copying them and propagating them in one’s own name is unethical. This applies to any creative work, program or design. Establishing ownership on a work which is not yours is ethically wrong.
  9. Thou shalt think about the social consequences of the program you are writing or the system you are designing.
    Simply put: Before developing a software, think about the social impact it can have. Explanation: Looking at the social consequences that a program can have, describes a broader perspective of looking at technology. A computer software on release, reaches millions. Software like video games and animations or educational software can have a social impact on their users. When working on animation films or designing video games, for example, it is the programmer’s responsibility to understand his target audience/users and the effect it may have on them. For example, a computer game for kids should not have content that can influence them negatively. Similarly, writing malicious software is ethically wrong. A software developer/development firm should consider the influence their code can have on the society at large.
  10. Thou shalt always use a computer in ways that ensure consideration and respect for other humans.
    Simply put: In using computers for communication, be respectful and courteous with the fellow members. Explanation: The communication etiquette we follow in the real world applies to communication over computers as well. While communicating over the Internet, one should treat others with respect. One should not intrude others’ private space, use abusive language, make false statements or pass irresponsible remarks about others. One should be courteous while communicating over the web and should respect others’ time and resources. Also, one should be considerate with a novice computer user.

Passwords

Intro

Passwords are critical to your safety. Take whatever it costs to manage them well!

IDEAS

Despite all their weaknesses, it looks as if passwords will stay for the foreseeable future. These are couple of steps people can take to strengthen their passwords so that it is less likely hackers can break into their accounts.

  • Perhaps the most important step is to not re-use the same password across different websites.
  • It is convenient only having one password, but this means that if someone guesses, or steals one of your passwords, they can then use that to gain access to any of your other accounts.
  • Using a password manager can help create and remember all the different passwords.
  • Failing that, even writing passwords down can be good in some cases (just don’t leave your notebook lying around).
  • The second step is to take advantage of two factor authentication (2FA) wherever it is available.
  • For many sites that offer this service, in addition to entering username and password, it will send a code via text message to your phone which will need to be entered.
  • Third, and finally, people should be wary of the scams which try to steal their passwords.
  • For example, receiving an email with a link from a large provider such as Microsoft, Amazon, or Apple, and asking people to re-enter their username and password or risk having their account frozen.
  • People should never click on such links in emails, and only navigate manually to any sites they wish to visit if they need to log onto their accounts.

Check your password strenght:

RegEx

Intro

Regular expressions are a language of their own. When you learn a new programming language, they’re this little sub-language that makes no sense at first glance. Many times you have to read another tutorial, article, or book just to understand the “simple” pattern described. Today, we’ll review eight regular expressions that you should know for your next coding project.
Regular Expressions aka Regex are expressions that define a search pattern. They are widely used for validation purposes, like email validation, url validation, phone number validation and so on

Commonly used RegEx

Digits

Alphanumeric Characters

Email

Password Strength

  • Complex: Should have 1 lowercase letter, 1 uppercase letter, 1 number, 1 special character and be at least 8 characters long
    /(?=(.*[0-9]))(?=.*[\!@#$%^&*()\\[\]{}\-_+=~`|:;”‘<>,./?])(?=.*[a-z])(?=(.*[A-Z]))(?=(.*)).{8,}/
  • Moderate: Should have 1 lowercase letter, 1 uppercase letter, 1 number, and be at least 8 characters long
    /(?=(.*[0-9]))((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.{8,}$/

Username

  • Alphanumeric string that may include _ and – having a length of 3 to 16 characters –
    /^[a-z0-9_-]{3,16}$/

URL

  • Include http(s) Protocol /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&//=]*)/
  • Protocol Optional /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/

IP Address

123456/* Match IPv4 address *//^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/ /* Match IPv6 address *//(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))//* Match both IPv4, IPv6 addresses *//((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/

Dates

12345678910111213/* Date Format YYYY-MM-dd *//([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/ /* Date Format dd-MM-YYYY or dd.MM.YYYY ordd/MM/YYYYwith check for leap year *//^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/ /* Date Format dd-mmm-YYYY ordd/mmm/YYYY ordd.mmm.YYYY *//^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/

Time

HTML Tags

Javascript Handlers

Slug

  • Slug
    /^[a-z0-9]+(?:-[a-z0-9]+)*$/

Match Duplicates in a String

14. Phone Numbers

12/* International Phone Numbers *//^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/

Note: Use regex for validating phone numbers only if you don’t have the choice to use a library. There are several libraries that handle phone numbers more accurately and should be used instead.

File Path

Regex Tools

Resources

  • https://www.debuggex.com/
  • https://regex101.com/