Shell: Unterschied zwischen den Versionen

Aus Doc-Wiki
Zur Navigation springen Zur Suche springen
imported>Burghardt
imported>Burghardt
Zeile 1: Zeile 1:
 
{| style="border: 1pt black dashed"
 
{| style="border: 1pt black dashed"
 
|-
 
|-
| [[Image:Diamond-caution.png]] || Beta Test. Please give feedback via '''<tt>feedback(ät)informatik.uni-goettingen.de</tt>'''<br />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.<br />Currently most important topic: [[#Port_knocking]] <br />Second most topic: moving away from knocking - going [[#2FA]]|| [[Image:Diamond-caution.png]]
+
| [[Image:Diamond-caution.png]] || Beta Test. Please give feedback via '''<tt>feedback(ät)informatik.uni-goettingen.de</tt>'''<br />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.<br />Currently most important topic: [[#2FA]]|| [[Image:Diamond-caution.png]]
 
|-
 
|-
 
|}
 
|}
Zeile 8: Zeile 8:
   
 
== Usage ==
 
== Usage ==
''Please read [[#Port_knocking]] if you can not connect.''
+
''Please read [[#2FA]] for initial contact.''
   
   
 
Simply use SSH to login to this machine:
 
Simply use SSH to login to this machine:
 
<big>
 
<big>
'''ssh user@shell.stud.informatik.uni-goettingen.de'''
+
~# 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>
 
</big>
Note that the intially presented banner contains something like
 
   
####### shell.stud.informatik.uni-goettingen.de - login vm: '''shell5.cip.loc'''
 
...telling you the actual local name of the automatically chosen destination machine.
 
   
   
Zeile 41: Zeile 44:
 
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>
 
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 ==
 
== Self defense of these servers ==
 
''<small>There used to be some other mechanisms. The only one left currently is "Port knocking"</small>''
 
''<small>There used to be some other mechanisms. The only one left currently is "Port knocking"</small>''
<!--
 
 
=== Rate Limiting ===
 
=== 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:
 
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:
Zeile 62: Zeile 67:
   
 
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.
 
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 ===
 
=== Port knocking ===
Zeile 106: Zeile 110:
   
 
==== Windows ====
 
==== 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
 
* <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
 
* 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
 
* Use a web browser to tickle those ports
Zeile 130: Zeile 132:
   
 
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.
 
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 ==
 
== 2FA ==
''Two Factor Authentication'' -- ''Not activated yet (except on shell4)''
+
''Two Factor Authentication''
 
   
 
=== Concept ===
 
=== 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.
 
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.
   
The used approach is called TOTP = Time-based One Time Password. (Just for reference: the wide spread alternative is "HOTP", Hash-base OTP. For this one you need a YubiKey or an RSA-Token.)
+
The used approach is called TOTP = Time-based One Time Password. <small>(Just for reference: the wide spread alternative is "HOTP", Hash-base OTP. For this one you need a YubiKey or an RSA-Token.) </small>
 
 
 
You need to have a corresponding generator - usually implemented as a small application. See [[#Generators]]
 
You need to have a corresponding 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 ''compatible'' implementations. See also RFC 6238
+
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 ===
 
=== Initialization ===
Befor you can use this technology the first time you need to prepare your personal secret credentials. You do this by using a tool with a surprising name and answering the questiuons:
+
Before you can use this technology the first time you need to prepare your personal secret credentials. You do this by using a tool with a surprising name and answering the questions:
   
 
~$ '''google-authenticator'''
 
~$ '''google-authenticator'''
 
Do you want authentication tokens to be time-based (y/n) y
 
Do you want authentication tokens to be time-based (y/n) y
 
... <small># For full output see [[Shell/2fa-example]]</small>
...
 
# For full output see [[Shell/2fa-example]]
 
   
Due to some unusual behaviour of OpenAFS regarding access rights we need to move that file into a different, dedicated subdirectory. The man page explains the access rights mechanism and how to manipulate ''access-control-lists'':
+
Due to some unusual behaviour of [[OpenAFS]] regarding access rights we need to move that file into a different, dedicated subdirectory. This man page explains the access rights mechanism and how to manipulate ''access-control-lists'':
 
~$ man fs_setacl
 
~$ 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 that directory. 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:
+
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 that directory. 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
 
~$ mkdir .ifi-login
 
~$ fs sa -dir .ifi-login -acl ifi-login read
 
~$ fs sa -dir .ifi-login -acl ifi-login read
Zeile 175: Zeile 175:
 
ifi-login 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!
+
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:
 
Now move the created credential file into that new destination:
Zeile 238: Zeile 238:
 
####### shell.stud.informatik.uni-goettingen.de - login vm: shell4.cip.loc
 
####### shell.stud.informatik.uni-goettingen.de - login vm: shell4.cip.loc
   
 
<!--
 
=== "knocking" not required from ''inside'' the Institute ===
 
=== "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:
 
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
 
~$ ssh shell4.cip.loc
 
-->
  +
   
 
== Todo ==
 
== Todo ==
Zeile 252: Zeile 255:
   
 
== Links ==
 
== Links ==
* https://en.wikipedia.org/wiki/Port_knocking
+
* 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
 
* 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>
 
* 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>

Version vom 14. Juni 2016, 07: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.
Currently most important topic: #2FA
Diamond-caution.png


Usage

Please read #2FA for initial contact.


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.)

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.

The used approach is called TOTP = Time-based One Time Password. (Just for reference: the wide spread alternative is "HOTP", Hash-base OTP. For this one you need a YubiKey or an RSA-Token.)

You need to have a corresponding 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 tool with a surprising name and answering the questions:

~$ 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 behaviour of OpenAFS regarding access rights we need to move that file into a different, 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 that directory. 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!

Usage

From another Linux system it looks like this (shortened):

~$ ssh username@shell4.cip.loc
...
Password: 
Verification code: 
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-87-generic x86_64)
...
username@shell4:~$ 

Generators

  • Linux
    • ...
  • Ubuntu Touch
    • Authenticator
  • Windows:
    • ...
  • OS agnostic

Error Messages

If the above preparation did not result in a valid setup and you've entered the correct password - you will get an error message like:

...
##
Password: 
/usr/local/sbin/fetch-secrets failed: exit code 12

Problems, Todo

  • Testing!
  • how do scripts handle this?
  • require 2FA only from outside the Institute

Additionally...

If you have problems to login take a look at this page. These security aspects are definitely a work in progress and probably the final state is not reached yet...

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". With the advent of #2FA --> back to "alpha"...
  • make Status Information publicly available

See also


Links