Benutzer:Burghardt/Tox und Shell: Unterschied zwischen den Seiten

Aus Doc-Wiki
< Benutzer:Burghardt(Unterschied zwischen Seiten)
Zur Navigation springen Zur Suche springen
imported>Burghardt
(Die Seite wurde neu angelegt: „ == Nutzer == * '''UdoBurghardt''' (= privat) EA7AC07EDBAC3138725AE118323F64BB2B9D1BAAA5CF0E1B49805B14FCA83D12856532D0FA2E * '''Udo Burghardt (ifi)''' (primär…“)
 
imported>Burghardt
 
Zeile 1: Zeile 1:
  +
{| style="border: 1pt black dashed"
  +
|-
  +
| [[Image:Diamond-caution.png]] || '''Beta Test!''' Please give feedback via '''<tt>feedback(ät)informatik.uni-goettingen.de</tt>'''<br /><small>For problem reports: please include ''always'' information about your system, the exact date+time, your IP address, your user id, what you wanted to accomplish, what you did and what happened instead.</small>|| [[Image:Diamond-caution.png]]
  +
|-
  +
|}
   
== Nutzer ==
 
   
  +
* '''UdoBurghardt''' (= privat)
 
  +
== Usage ==
EA7AC07EDBAC3138725AE118323F64BB2B9D1BAAA5CF0E1B49805B14FCA83D12856532D0FA2E
 
  +
''Please read [[#2FA]] for initial contact.'' Then simply use SSH to login to this machine:
* '''Udo Burghardt (ifi)''' (primär=tmg82)
 
  +
71AAB7F6F010CD2D94A53310E701CD82589EE7AB9346308C8FA962A9762FF66F509024F07388
 
  +
<big>
  +
~# ssh username@shell.stud.informatik.uni-goettingen.de
  +
####### shell.stud.informatik.uni-goettingen.de - login vm: shell5.cip.loc
  +
...
  +
'''Password: '''
  +
'''Verification code: '''
  +
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-87-generic x86_64)
  +
username@shell5:~$
  +
</big>
  +
  +
  +
  +
For '''Windows''': use [[PuTTY]] (simple) or [[Cygwin]] (more complex and powerful) or any other SSH-implementation.
  +
  +
  +
=== Target audience ===
  +
These machines are meant to be used by students. But ''of course'' they can be used by any staff members!
  +
  +
For first time users: the only requirement is to logon one single time using one of the (physical) pool computers in our building - this will make you a "known user" to our systems. Additionally you need to walk through [[#2FA]].
  +
  +
=== Load Balancing ===
  +
While this term is misleading on this specific installation as it does simple "round-robin". The important point is that you'll get connected to ''any'' login machine. This will be the "next" machine one after another and probably ''not'' the same one as one session before. If you landed on an overcrowded system simply disconnect/reconnect to use another machine.
  +
<!--
  +
=== Legacy <tt>login.stud</tt> ===
  +
Both <tt>login.stud.informatik.uni-goettingen.de</tt> and <tt>login.informatik.uni-goettingen.de</tt> (for staff only) are not affected by this new approach. These "old" machines will continue to work unmodified.
  +
-->
  +
  +
=== Timeout ===
  +
* The session Timeout is set to '''36 hours''' -- this is the HAproxy related Timeout regarding the TCP connection
  +
* [[Kerberos]]/[[OpenAFS]] have separate/shorter timeouts, usually 10 hours. Please check with <tt>klist</tt>. You need to run <tt>kinit && aklog</tt> when you're approaching timeout
  +
  +
<!--
  +
=== Availability ===
  +
The goal - ''of course'' - is 24/7. Take a look at: http://shell.stud.informatik.uni-goettingen.de/ -- use <tt>ifi</tt>/<tt>ifi</tt> to login <small>("bots not welcome")</small>
  +
-->
  +
  +
  +
<!--
  +
  +
== Self defense of these servers ==
  +
''<small>There used to be some other mechanisms. The only one left currently is "Port knocking"</small>''
  +
=== Rate Limiting ===
  +
Usually we do utilize "<tt>fail2ban</tt>" to chase brute force attacks by bad guys trying to hack login credentials. For technical reasons this is not possible for this "<tt>haproxy</tt>" approach. The inconvenient workaround is:
  +
  +
{| style="border: 1pt black dashed"
  +
|-
  +
| [[Image:Diamond-caution.png]] || We do limit the rate of ''new'' <tt>ssh</tt>- (<tt>tcp</tt>-) connections from any given source IP address to '''1 per minute'''. <br />This rate will get increased when "port knocking" is established.|| [[Image:Diamond-caution.png]]
  +
|-
  +
|}
  +
  +
When you're going to login via ssh you usually have three tries to enter your password. Technically this is just ''one'' single connection! The next three tries come with the next connection, which is only possible after one minute. Trying to to log in too early gives just a generic error message:
  +
  +
~# ssh username@shell.stud.informatik.uni-goettingen.de
  +
ssh_exchange_identification: read: Connection reset by peer
  +
  +
This behavior should be fine for most users where each one has a different IP address than other people.
  +
  +
If you are a group of students behind NAT this could be a problem. We need yet to find out if this might be a problem for students residential establishment in Göttingen.
  +
  +
=== Port knocking ===
  +
For security reasons a "port knocking daemon" got installed. It works like a secret knocking sequence at the door of a conspiracy meeting: only after you have successfully performed that secret sequence the door is opened ''for a moment''. In our technical context this means that the listening <tt>sshd</tt> is ''reachable'' '''for 300 seconds''' after knocking...
  +
  +
{| style="border: 1pt black dashed"
  +
|-
  +
| [[Image:Diamond-caution.png]] || Secret: 33778 &bull; 22999 &bull; 44333 || [[Image:Diamond-caution.png]]
  +
|-
  +
|}
  +
  +
{| style="border: 1pt black dashed"
  +
|-
  +
| [[Image:Diamond-caution.png]] || This approach will get removed during the next days... || [[Image:Diamond-caution.png]]
  +
|-
  +
|}
  +
  +
  +
Successfully triggering is possible using a variety of software tools:
  +
  +
* [[#Linux]]
  +
* [[#Windows]]
  +
* [[#Android]]
  +
* [[#OS agnostic Web Browser]]
  +
  +
==== Linux ====
  +
If you are using Linux and the package <tt>knockd</tt> is actually installed (which is not a requirement!) you can use this one-liner to log in:
  +
~$ knock shell.stud.informatik.uni-goettingen.de 33778 22999 44333 && sleep 1; ssh username@shell.stud.informatik.uni-goettingen.de
  +
  +
If this fails try a slower version:
  +
~$ knock shell.stud.informatik.uni-goettingen.de 33778; knock shell.stud.informatik.uni-goettingen.de 22999; knock shell.stud.informatik.uni-goettingen.de 44333 && sleep 1; ssh username@shell.stud.informatik.uni-goettingen.de
  +
  +
  +
''Without'' having the package <tt>knockd</tt> installed: <tt>telnet</tt> to the rescue!
  +
~$ telnet shell.stud.informatik.uni-goettingen.de 33778
  +
~$ telnet shell.stud.informatik.uni-goettingen.de 22999
  +
~$ telnet shell.stud.informatik.uni-goettingen.de 44333
  +
~$ ssh username@shell.stud.informatik.uni-goettingen.de
  +
  +
  +
  +
[[Image:knockknock.png|343px|right]]
  +
  +
==== Windows ====
  +
* <tt>telnet</tt> is included in Windows also. But it is not ''installed'' by default. You need to activate it through "Windows-Features aktivieren oder deaktivieren"/"Add windows features" "Telnet-Client". You need Administrator privileges to do so, so this is not an option on foreign computers
  +
* There are dedicated tools available for this purpose. This one is tested and found to work as expected: https://sourceforge.net/projects/knockknock/ <br />The zip-file contains a (surprisingly small) executable. It is usable without installation, so you do ''not'' need Admin privileges
  +
* Use a web browser to tickle those ports
  +
* <small><tt>telnet</tt> is included in Windows also, but unfortunately it seems not to work reliably. During reproducible tests the ''third'' knock did not reach the server while the first two were handled correctly</small>
  +
&nbsp;<br />&nbsp;
  +
  +
==== Android ====
  +
"Port Knocker" via [[F-Droid]]: It is recommended to integrate that repository by installing https://f-droid.org/FDroid.apk. A direct link to the relevant package is: https://f-droid.org/repo/com.xargsgrep.portknocker_8.apk
  +
  +
This tool allows an arbitrary application to launch automatically after knocking. Tested successfully with [[ConnectBot]].
  +
  +
  +
==== OS agnostic Web Browser ====
  +
  +
Create a new folder for these bookmarks. Prepare three Bookmarks:
  +
** http://shell.stud.informatik.uni-goettingen.de:33778
  +
** http://shell.stud.informatik.uni-goettingen.de:22999
  +
** http://shell.stud.informatik.uni-goettingen.de:44333
  +
  +
Of course you will end up running into a timeout as ''there is no webserver listening''. You do not have to wait for timeout; simply cancel loading...
  +
  +
You can "click" them one after another. Browsers like [[Firefox]] offer a context menu entry "Alle in Tabs öffnen"/"Open all bookmarks" which tries to do what it says. You need to close all three of them one by one though.
  +
-->
  +
  +
== 2FA ==
  +
''Two Factor Authentication''
  +
  +
=== Concept ===
  +
We use the well known <tt>google-authenticator</tt> to add a second factor as a requirement for (ssh-) logins. First you will get prompted for your regular password. Then you'll get a second prompt asking for a "Verification code". This code changes every minute, this approach is called TOTP = Time-based One Time Password.
  +
  +
You need to have a compatible generator - usually implemented as a small application. See [[#Generators]]
  +
  +
Please note that often this approach is associated with a specific implementation: ''the'' [[Google Authenticator]]. This is misleading as there are other 100% compatible implementations. See also RFC 6238.
  +
  +
=== Initialization ===
  +
Before you can use this technology the first time you need to prepare your personal secret credentials. You do this by using a simple command line tool and answering some questions.
  +
  +
Of course you can not do this on these shellX-machines as you can not login successfully (chicken-and-egg problem). Use one of the physical pool computers or login.stud.informatik.uni-goettingen.de instead.
  +
  +
  +
~$ '''google-authenticator'''
  +
Do you want authentication tokens to be time-based (y/n) y
  +
... <small># For full output see [[Shell/2fa-example]]</small>
  +
  +
Due to some unusual behavior of [[OpenAFS]] regarding access rights (<small>they work ''only'' on directories, not on files</small>) we need to move that file into another, dedicated subdirectory. This man page explains the access rights mechanism and how to manipulate ''access-control-lists'':
  +
~$ man fs_setacl
  +
  +
First you need to create that directory. A special user with the name <tt>ifi-login</tt> needs to have read access to the files in the directory <tt>.ifi-login</tt> inside of your <tt>$HOME</tt>. To be able to reach into that directory he needs to "walk through" your home folder. The third line is required to make this possible by granting "l"="list" access rights to your <tt>$HOME</tt>:
  +
~$ mkdir .ifi-login
  +
~$ fs sa -dir .ifi-login -acl ifi-login read
  +
~$ fs sa -dir . -acl ifi-login l
  +
  +
As usual access rights are inherited. For this reason there are more rights granted than required. You ''might'' remove them now by commands like
  +
~$ fs sa -dir .ifi-login -acl mta none
  +
~$ fs sa -dir .ifi-login -acl spamassassin none
  +
~$ fs sa -dir .ifi-login -acl web-home none
  +
  +
You can always check the current settings. At the end it may look like this:
  +
~$ fs la .ifi-login
  +
Access list for .ifi-login is
  +
Normal rights:
  +
system:administrators rlidwka
  +
username rlidwka
  +
username.system rl
  +
ifi-login rl
  +
  +
WARNING: do not remove rights if you are not absolutely sure they are not needed. ''It is very easy to remove too many rights'', leaving you with a directory that is not usable anymore!
  +
  +
Now move the created credential file into that new destination:
  +
~$ mv .google_authenticator .ifi-login/
  +
  +
Please remember to repeat this step if you modify your configuration!
  +
  +
=== Generators ===
  +
{| style="border: 1pt black dashed"
  +
|-
  +
| [[Image:Diamond-caution.png]] || The system time is used equivalent to a shared secret! Make sure your clock is set correctly or all generated codes will fail.
  +
|-
  +
|}
  +
  +
For all generators you need the secret created above. You can use any tool you want to look into the file <tt>.ifi-login/.google_authenticator</tt>. A one-liner which outputs ''only'' the "secret" is this:
  +
~$ head -n1 .ifi-login/.google_authenticator
  +
P2ZOMKQLEIC6SKCL
  +
  +
[[Image:winauth+putty.png|399px|right]]
  +
  +
* Android
  +
** Play Store: "<tt>Google Authenticator</tt>".
  +
** [[F-Droid]]: https://f-droid.org/app/com.google.android.apps.authenticator2
  +
  +
* Linux
  +
** install <tt>oathtool</tt> to get some compatible command line utilities. Then this works:
  +
~$ oathtool --totp -b $(head -n1 .ifi-login/.google_authenticator)
  +
123456
  +
  +
* Ubuntu Touch
  +
** Authenticator
  +
  +
* Windows:
  +
** WinAuth: https://github.com/winauth/winauth -- <small>direct download as of 06.2016: https://winauth.com/downloads/3.x/WinAuth-3.5.1.zip</small><br />This is an installation-free application, no setup and no administrative access needed.
  +
  +
* OS agnostic
  +
** [[Chromium]] Browser: GAuth application
  +
** https://5apps.com/gbraad/gauth -- direct use web-application (think twice!) & application for Chrome and Firefox
  +
  +
== Tips 'n' Tricks ==
  +
  +
=== Connect to a specific machine ===
  +
Circumventing the Round-Robin mechanism is possible: connect to a specific port <tt>42000+''n''</tt> with <tt>''n''={1..6}</tt> :-)
  +
  +
For machine number 4:
  +
  +
~$ ssh -p 42004 username@shell.stud.informatik.uni-goettingen.de
  +
#######
  +
####### shell.stud.informatik.uni-goettingen.de - login vm: shell4.cip.loc
  +
  +
<!--
  +
=== "knocking" not required from ''inside'' the Institute ===
  +
If your are ''inside'' the Institute's LAN then there is no need to take the main entrance. You can circumvent the need to knock at the front door by connecting to the <tt>shellX</tt>-machines directly:
  +
~$ ssh shell4.cip.loc
  +
-->
  +
  +
  +
== Todo ==
  +
* Testing! -- the current state is considered "BETA"
  +
<!-- * make Status Information publicly available? -- ''probably not'' -->
  +
* possibly require 2FA only from outside the Institute? --> ''Not decided yet''
  +
  +
== See also ==
  +
* [[Remote Access]]
  +
* [[Long Running Processes]]
  +
  +
  +
== Links ==
  +
* https://tools.ietf.org/html/rfc6238
  +
* https://github.com/google/google-authenticator
  +
  +
<!--
  +
* https://en.wikipedia.org/wiki/Port_knocking
  +
* https://help.ubuntu.com/ -- common help regarding Ubuntu
  +
* http://shell.stud.informatik.uni-goettingen.de/ -- current state of the load balancer. Use <tt>ifi</tt>/<tt>ifi</tt> to login <small>''("bots not welcome")''</small>
  +
-->
  +
  +
[[Category:Pool]][[Category:Remote]]

Version vom 14. Juni 2016, 14:48 Uhr

Diamond-caution.png Beta Test! Please give feedback via feedback(ät)informatik.uni-goettingen.de
For problem reports: please include always information about your system, the exact date+time, your IP address, your user id, what you wanted to accomplish, what you did and what happened instead.
Diamond-caution.png


Usage

Please read #2FA for initial contact. Then simply use SSH to login to this machine:

~# ssh username@shell.stud.informatik.uni-goettingen.de 
#######  shell.stud.informatik.uni-goettingen.de - login vm: shell5.cip.loc
...
Password: 
Verification code: 
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-87-generic x86_64)
username@shell5:~$ 


For Windows: use PuTTY (simple) or Cygwin (more complex and powerful) or any other SSH-implementation.


Target audience

These machines are meant to be used by students. But of course they can be used by any staff members!

For first time users: the only requirement is to logon one single time using one of the (physical) pool computers in our building - this will make you a "known user" to our systems. Additionally you need to walk through #2FA.

Load Balancing

While this term is misleading on this specific installation as it does simple "round-robin". The important point is that you'll get connected to any login machine. This will be the "next" machine one after another and probably not the same one as one session before. If you landed on an overcrowded system simply disconnect/reconnect to use another machine.

Timeout

  • The session Timeout is set to 36 hours -- this is the HAproxy related Timeout regarding the TCP connection
  • Kerberos/OpenAFS have separate/shorter timeouts, usually 10 hours. Please check with klist. You need to run kinit && aklog when you're approaching timeout



2FA

Two Factor Authentication

Concept

We use the well known google-authenticator to add a second factor as a requirement for (ssh-) logins. First you will get prompted for your regular password. Then you'll get a second prompt asking for a "Verification code". This code changes every minute, this approach is called TOTP = Time-based One Time Password.

You need to have a compatible generator - usually implemented as a small application. See #Generators

Please note that often this approach is associated with a specific implementation: the Google Authenticator. This is misleading as there are other 100% compatible implementations. See also RFC 6238.

Initialization

Before you can use this technology the first time you need to prepare your personal secret credentials. You do this by using a simple command line tool and answering some questions.

Of course you can not do this on these shellX-machines as you can not login successfully (chicken-and-egg problem). Use one of the physical pool computers or login.stud.informatik.uni-goettingen.de instead.


~$ google-authenticator      
Do you want authentication tokens to be time-based (y/n) y
... # For full output see Shell/2fa-example

Due to some unusual behavior of OpenAFS regarding access rights (they work only on directories, not on files) we need to move that file into another, dedicated subdirectory. This man page explains the access rights mechanism and how to manipulate access-control-lists:

~$ man fs_setacl

First you need to create that directory. A special user with the name ifi-login needs to have read access to the files in the directory .ifi-login inside of your $HOME. To be able to reach into that directory he needs to "walk through" your home folder. The third line is required to make this possible by granting "l"="list" access rights to your $HOME:

~$ mkdir .ifi-login     
~$ fs sa -dir .ifi-login -acl ifi-login read 
~$ fs sa -dir . -acl ifi-login l

As usual access rights are inherited. For this reason there are more rights granted than required. You might remove them now by commands like

~$ fs sa -dir .ifi-login -acl mta none
~$ fs sa -dir .ifi-login -acl spamassassin none
~$ fs sa -dir .ifi-login -acl web-home none

You can always check the current settings. At the end it may look like this:

~$ fs la .ifi-login
Access list for .ifi-login is
Normal rights:
 system:administrators rlidwka
 username rlidwka
 username.system rl
 ifi-login rl

WARNING: do not remove rights if you are not absolutely sure they are not needed. It is very easy to remove too many rights, leaving you with a directory that is not usable anymore!

Now move the created credential file into that new destination:

~$ mv .google_authenticator .ifi-login/

Please remember to repeat this step if you modify your configuration!

Generators

Diamond-caution.png The system time is used equivalent to a shared secret! Make sure your clock is set correctly or all generated codes will fail.

For all generators you need the secret created above. You can use any tool you want to look into the file .ifi-login/.google_authenticator. A one-liner which outputs only the "secret" is this:

~$ head -n1 .ifi-login/.google_authenticator 
P2ZOMKQLEIC6SKCL
Winauth+putty.png
  • Linux
    • install oathtool to get some compatible command line utilities. Then this works:
~$ oathtool --totp -b $(head -n1 .ifi-login/.google_authenticator)
123456
  • Ubuntu Touch
    • Authenticator

Tips 'n' Tricks

Connect to a specific machine

Circumventing the Round-Robin mechanism is possible: connect to a specific port 42000+n with n={1..6} :-)

For machine number 4:

~$ ssh -p 42004 username@shell.stud.informatik.uni-goettingen.de
#######
#######  shell.stud.informatik.uni-goettingen.de - login vm: shell4.cip.loc


Todo

  • Testing! -- the current state is considered "BETA"
  • possibly require 2FA only from outside the Institute? --> Not decided yet

See also


Links