Como posso criar um login SSH que delega para telnet com segurança

2

Estou brincando com a idéia de criar um MUD, mas um dos lados ruins é que eles usam "telnet", que é inseguro. Gostaria de manter a capacidade de usuários "anônimos" acessarem uma conta específica, e a única conta que eles fazem é telnet para uma porta local.

Então, em outras palavras, o que eu quero é poder dizer a qualquer pessoa / todos que eles podem executar:

ssh [email protected] para "conectar" a minha lama com segurança.

A conta "anônima" executaria um "telnet localhost: 34843", ou algum comando similar. Idealmente, a conta anônima não tem absolutamente nenhum outro acesso. Nenhum encaminhamento de porta, nenhum arquivo (além daqueles necessários para a execução do telnet), etc ...

Se isso importa, provavelmente vou usar algum sabor do Ubuntu em um serviço de hospedagem em nuvem.

    
por Daniel 22.05.2015 / 03:29

2 respostas

4

Você pode configurar o OpenSSH para que uma determinada conta possa executar apenas um comando (o comando enviado pelo cliente é ignorado). Em /etc/ssh/sshd_config , adicione linhas como:

Match User anonymous
  ForceCommand /usr/bin/telnet localhost 34843
  PasswordAuthentication yes
  PermitEmptyPasswords yes
  AllowAgentForwarding no
  AllowTcpForwarding no
  PermitTTY yes
  PermitTunnel no
  X11Forwarding no

Você deve providenciar para que o diretório home de anonymous seja de propriedade root e somente modificável por root, e idem para ~anonymous/.ssh e os arquivos de lá.

Há pelo menos mais uma coisa que você precisa fazer, que é desativar os escapes do shell. Pelo menos algumas implementações de telnet permitem ao usuário escapar para um shell pressionando Ctrl + ] ! . Com a implementação do netkit do Linux, acho que telnet -e '' desativa o modo de comando e, portanto, torna impossível alcançar um shell a partir do telnet. Configurar o ambiente SHELL para /bin/false também seria uma precaução útil.

    
por 23.05.2015 / 00:55
0

É possível tornar um telnet seguro usando essas soluções

A) Um túnel ssh, é um absurdo (por que usar o túnel quando você pode usar o ssh?), mas funciona

ssh -L 23:localhost:23 -N -f your host

Claro, feche a porta 23 com firewall e deixe abrir a porta pessoal 22 ou ssh para proibir o acesso direto ao telnet

B) Um stunnel tls ou ssl (eu prefiro o TLS), é muito fácil de fazer, no servidor que você usa

; Sample stunnel configuration file for Unix by Michal Trojnara 2002-2012
; Some options used here may be inadequate for your particular configuration
; This sample file does *not* represent stunnel.conf defaults
; Please consult the manual for detailed description of available options
; **************************************************************************
; * Global options                                                         *
; **************************************************************************
; A copy of some devices and system files is needed within the chroot jail
; Chroot conflicts with configuration file reload and many other features
chroot = /var/lib/stunnel/
; Chroot jail can be escaped if setuid option is not used
setuid = nobody
setgid = nogroup
; PID is created inside the chroot jail
pid = /stunnel.pid
; Debugging stuff (may useful for troubleshooting)
;debug = 7
;output = stunnel.log
; **************************************************************************
; * Service defaults may also be specified in individual service sections  *
; **************************************************************************
; Certificate/key is needed in server mode and optional in client mode
cert = //etc/ssl/certs/yourserver.crt
key = //etc/ssl/private/yourserver.key
; Authentication stuff needs to be configured to prevent MITM attacks
; It is not enabled by default!
verify = 2
; Don't forget to c_rehash CApath
; CApath is located inside chroot jail
;CApath = /
; It's often easier to use CAfile
CAfile = /yourserver.ca
; Don't forget to c_rehash CRLpath
; CRLpath is located inside chroot jail
;CRLpath = /crls
; Alternatively CRLfile can be used
;CRLfile = /usr/etc/stunnel/crls.pem
; Disable support for insecure SSLv2 protocol
options = NO_SSLv2
; Workaround for Eudora bug
;options = DONT_INSERT_EMPTY_FRAGMENTS
; These options provide additional security at some performance degradation
;options = SINGLE_ECDH_USE
;options = SINGLE_DH_USE
; **************************************************************************
; * Service definitions (remove all services for inetd mode)               *
; **************************************************************************
; Example SSL server mode services
[telnet]
accept  = 0.0.0.0:5939
connect = 23

no cliente

; Sample stunnel configuration file for Unix by Michal Trojnara 2002-2012
; Some options used here may be inadequate for your particular configuration
; This sample file does *not* represent stunnel.conf defaults
; Please consult the manual for detailed description of available options
client=yes

; **************************************************************************
; * Global options                                                         *
; **************************************************************************

; A copy of some devices and system files is needed within the chroot jail
; Chroot conflicts with configuration file reload and many other features
;chroot = /var/lib/stunnel/
; Chroot jail can be escaped if setuid option is not used
;setuid = nobody
;setgid = nogroup

; PID is created inside the chroot jail
;pid = /stunnel.pid

; Debugging stuff (may useful for troubleshooting)
;debug = 7
;output = stunnel.log

; **************************************************************************
; * Service defaults may also be specified in individual service sections  *
; **************************************************************************

; Certificate/key is needed in server mode and optional in client mode
cert = /yourclient.crt
key  = /yourclient.key

; Authentication stuff needs to be configured to prevent MITM attacks
; It is not enabled by default!
;verify = 2
; Don't forget to c_rehash CApath
; CApath is located inside chroot jail
;CApath = /certs
; It's often easier to use CAfile
CAfile = /yourca.crt
; Don't forget to c_rehash CRLpath
; CRLpath is located inside chroot jail
;CRLpath = /crls
; Alternatively CRLfile can be used
;CRLfile = /usr/etc/stunnel/crls.pem

; Disable support for insecure SSLv2 protocol
options = NO_SSLv2
; Workaround for Eudora bug
;options = DONT_INSERT_EMPTY_FRAGMENTS

; These options provide additional security at some performance degradation
;options = SINGLE_ECDH_USE
;options = SINGLE_DH_USE

; **************************************************************************
; * Service definitions (remove all services for inetd mode)               *
; **************************************************************************

; Example SSL server mode services

[telnet]
accept=localhost:23
connect=yourstunnelserver:5939

Claro, use esses arquivos apenas por exemplo e modifique para sua configuração Você acessará o servidor remoto

telnet localhost 23 

usando um túnel tls seguro

O terceiro método é usar telnet com keberos, é legal porque nenhum passwd perguntou e permite um SSO, mas requer cifras fracas, então não é 100% seguro

no inetd.conf edite e adicione ou modifique

telnet  stream  tcp     nowait  root    /usr/kerberos/sbin/telnetd 

no cliente

telnet -x server

Se conectar sem perguntar passe está funcionando, se receber pedir senha ou erro de mensagem, o telnet está claro

    
por 22.05.2015 / 03:47

Tags