<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Remote_Shell_RSH</id>
	<title>Remote Shell RSH - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Remote_Shell_RSH"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Remote_Shell_RSH&amp;action=history"/>
	<updated>2026-08-30T09:20:46Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=Remote_Shell_RSH&amp;diff=677&amp;oldid=prev</id>
		<title>Joan: /* comprovació en la xarxa remota */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Remote_Shell_RSH&amp;diff=677&amp;oldid=prev"/>
		<updated>2008-11-13T17:29:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;comprovació en la xarxa remota&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''Important!'''&lt;br /&gt;
El RSH ja no es fa servir i ha quedat substituït totalment pel SSH, que pot fer el mateix que el rsh, rlogin i rcp, perè de forma segura&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Secure Shell (SSH) is a secure replacement for telnet, rlogin, rsh, and rcp. It uses encryption to keep information that you send over the network from being seen by others. It also uses public and private keys to validate that the host and client machines are who they say they are. &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Per tant, i abans de continuar llegint, saber que el que importa és conèixer i tenir ben configurat el ssh, i també és molt interessant el scp per copiar fitxers de forma remota.&lt;br /&gt;
&lt;br /&gt;
The rsh package contains a set of programs which allow users to run commmands on remote machines, login to other machines and copy files between machines (rsh, rlogin and rcp). All three of these commands use rhosts style authentication. This package contains the clients and servers needed for all of these services. It also contains a server for rexec, an alternate method of executing remote commands. All of these servers are run by inetd and configured using /etc/inetd.conf and PAM. The rexecd server is disabled by default, but the other servers are enabled. The rsh package should be installed to enable remote access to other machines.&lt;br /&gt;
&lt;br /&gt;
http://ubuntuforums.org/showthread.php?t=276769&lt;br /&gt;
&lt;br /&gt;
Several things need to be in place:&lt;br /&gt;
&lt;br /&gt;
El client rsh ve instal.lat per defecte ($ rsh i veure que dóna opcions). Ara bé, per fer rsh entre dues màquines ha d'estar instal.lat el servidor rsh  a més del inetd.&lt;br /&gt;
&lt;br /&gt;
Several things need to be in place:&lt;br /&gt;
&lt;br /&gt;
1) in.rshd installed -&amp;gt; The in.rshd daemon is the server for the rsh(1) program.&lt;br /&gt;
&lt;br /&gt;
2) portmap running and enabled&lt;br /&gt;
&lt;br /&gt;
3) inetd / xinetd entries enabled and inetd service reloaded&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install rsh-server&lt;br /&gt;
&lt;br /&gt;
==Instal.lació servidor rsh (in.rshd)==&lt;br /&gt;
http://safari.oreilly.com/0130277010/ch09lev1sec16&lt;br /&gt;
&lt;br /&gt;
The in.rshd daemon is the server for the rsh(1) program. The server provides remote execution facilities with authentication based on privileged port numbers.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install rsh-server&lt;br /&gt;
$ /usr/sbin/in.rshd host.port&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
on host i port s'haurien de substituir per la IP a la que em vull connectar i per quin port. No dóna cap missatge, no estranyar-se.&lt;br /&gt;
&lt;br /&gt;
in.rshd is invoked by inetd(1M) each time a shell service is requested and executes the following protocol.&lt;br /&gt;
&lt;br /&gt;
The server checks the client's source address. If the address is associated with a host for which no corresponding entry exists in the host-name database (see hosts(4)), the server aborts the connection. Refer to &amp;quot;Security&amp;quot; for more details.&lt;br /&gt;
&lt;br /&gt;
rshd listens for service requests at port 514&lt;br /&gt;
&lt;br /&gt;
Ports: 514 when using old port based authentication, 544 for Kerberos 5 and non-encrypted Kerberos 4, and 545 for encrytpted Kerberos 4; subject of course to the contents of /etc/services&lt;br /&gt;
&lt;br /&gt;
==portmap: Mapeador de puertos de RPC==&lt;br /&gt;
&lt;br /&gt;
Portmap es un servidor que convierte números de programas RPC (Llamada a un Proceso Remoto, ''Remote Procedure Call'') en números de puertos del protocolo DARPA. Debe estar ejecutándose para hacer llamadas RPC.&lt;br /&gt;
&lt;br /&gt;
Entre los servicios que usan RPC se encuentran NFS y NIS.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install portmap&lt;br /&gt;
...&lt;br /&gt;
 * Starting portmap daemon...&lt;br /&gt;
&lt;br /&gt;
joan@ubuntu:/etc/init.d$ ps aux |grep portmap&lt;br /&gt;
daemon    1414  0.0  0.1   1812   456 ?        Ss   00:56   0:00 /sbin/portmap     &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dimoni inetd==&lt;br /&gt;
És el internet &amp;quot;super-server&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo /etc/init.d/inetd stop&lt;br /&gt;
sudo /etc/init.d/inetd start&lt;br /&gt;
sudo /etc/init.d/inetd restart&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
No dóna cap missatge, no estranyar-se.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      Inetd should be run at boot time by /etc/init.d/inetd (or /etc/rc.local&lt;br /&gt;
      on some systems).  It then listens for connections on certain internet&lt;br /&gt;
      sockets.  When a connection is found on one of its sockets, it decides&lt;br /&gt;
      what service the socket corresponds to, and invokes a program to service&lt;br /&gt;
      the request.  After the program is finished, it continues to listen on&lt;br /&gt;
      the socket (except in some cases which will be described below).  Essen-&lt;br /&gt;
      tially, inetd allows running one daemon to invoke several others, reduc-&lt;br /&gt;
      ing load on the system.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
És a dir, inetd escolta les peticions que li arriben d'internet (xarxa local o xarxa remota), i decideix quin és el programa que ha d'invocar per donar servei a la petició, en el nostre cas in.rshd, el servidor de remote shell&lt;br /&gt;
&lt;br /&gt;
Ubuntu utilitza inetd en comptes de xinetd.&lt;br /&gt;
&lt;br /&gt;
==1a prova==&lt;br /&gt;
després de fer la instal.lació, rsh localhost funciona&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rsh localhost&lt;br /&gt;
The authenticity of host 'localhost (127.0.0.1)' can't be established.&lt;br /&gt;
RSA key fingerprint is 37:25:5e:65:57:23:1d:df:0e:04:21:b9:ba:71:68:25.&lt;br /&gt;
Are you sure you want to continue connecting (yes/no)? yes&lt;br /&gt;
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.&lt;br /&gt;
...&lt;br /&gt;
Last login: Thu Nov 13 00:41:55 2008 from 193.153.6.191&lt;br /&gt;
joan@ubuntu:~$ exit&lt;br /&gt;
logout&lt;br /&gt;
Connection to localhost closed.&lt;br /&gt;
&lt;br /&gt;
$ rsh localhost ls -l #mostra els fitxers de la màquina a la que ens connectem, que és ella mateixa&lt;br /&gt;
#OK&lt;br /&gt;
$ rsh joan@localhost ls -l #OK&lt;br /&gt;
$ rsh -p 22 joan@localhost ls -la #OK, funciona pel port 22, com el SSH&lt;br /&gt;
ssh_exchange_identification: Connection closed by remote host&lt;br /&gt;
$ rsh -p 514 joan@localhost ls -la #falla&lt;br /&gt;
ssh_exchange_identification: Connection closed by remote host&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
el problema de configuració és per connectar-me des d'una màquina de la xarxa local i des d'una màquina remota.&lt;br /&gt;
&lt;br /&gt;
Ara bé, veig que no hi ha cap problema, perquè com que tinc SSH instal.lat, sembla ser que tot el tema de RSH es fa amb SSH i pel port 22.&lt;br /&gt;
&lt;br /&gt;
==Configuració de seguretat==&lt;br /&gt;
funciona perfectament tenint SSH ben configurat&lt;br /&gt;
&lt;br /&gt;
==client rsh==&lt;br /&gt;
http://manpages.ubuntu.com/manpages/intrepid/man1/krsh.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rsh [-45FGKdefnuxz] [-U string] [-p port] [-l username] [-P N|O] host [command]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
rsh authenticates to the rshd(8) daemon on the remote host, and then executes the specified command. rsh copies its standard input to the remote command, and the standard output and error of the remote command to its own.&lt;br /&gt;
&lt;br /&gt;
'''Exemples'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ client$ rsh otherhost cat remotefile &amp;gt; localfile&lt;br /&gt;
$ client$ rsh wikijoan.dyndns.org cat hola.txt &amp;gt; localfile&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
will write the contents of the remote remotefile to the local localfile, però compte, perque:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rsh otherhost ’cat remotefile &amp;gt; remotefile2’&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
el que farà és crear el fitxer en el remotefile2.&lt;br /&gt;
&lt;br /&gt;
===comprovació en la xarxa local===&lt;br /&gt;
Em pensava que no funcionaria a la primera i que tindria que barallar-me amb tot el tema de permisos i autentificació, però la veritat és que funciona a la primera, ja que tinc SSH ben configurat. Les proves les faré entre el portàtil (192.168.1.9) i el servidor (192.168.1.130). En el servidor tinc instal.lada la clau pública que es va generar en el portàtil, de manera que el servidor confia en el portàtil.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rsh&lt;br /&gt;
usage: ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]&lt;br /&gt;
           [-D [bind_address:]port] [-e escape_char] [-F configfile]&lt;br /&gt;
           [-i identity_file] [-L [bind_address:]port:host:hostport]&lt;br /&gt;
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]&lt;br /&gt;
           [-R [bind_address:]port:host:hostport] [-S ctl_path]&lt;br /&gt;
           [-w local_tun[:remote_tun]] [user@]hostname [command]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
El primer de tot és fixar-se que quan invoco rsh de fet estem invocant ssh. Per tant, aquí tinc un error conceptual i em fa pensar que tot el tema de rsh en realitat és ssh (calia instal.lar el servidor rsh?)&lt;br /&gt;
&lt;br /&gt;
Efectivament, la prova funciona i a la primera:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
portatil$ ssh 192.168.1.130 cat update.sql &amp;gt; update_portatil.sql&lt;br /&gt;
portatil$ rsh 192.168.1.130 cat update.sql &amp;gt; update_portatil.sql&lt;br /&gt;
&lt;br /&gt;
portatil$ cat update_posrtatil.sql&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
aquestes dues línies són equivalents (ssh i rsh), i el contingut del fitxer update.sql, del servidor, es copia en un fitxer del portàtil (client).&lt;br /&gt;
&lt;br /&gt;
===comprovació en la xarxa remota===&lt;br /&gt;
&lt;br /&gt;
ho provo des de l'institut. Com que no hi ha autentificació, hauré de posar login i pwd:&lt;br /&gt;
&lt;br /&gt;
 ssh joan@wikijoan.dyndns.org cat update.sql &amp;gt; update_portatil.sql&lt;br /&gt;
 password&lt;br /&gt;
&lt;br /&gt;
el fitxer update.sql el busca a /home/joan. Funciona.&lt;br /&gt;
&lt;br /&gt;
==rlogin==&lt;br /&gt;
 portatil$rlogin 192.168.1.130&lt;br /&gt;
és totalment equivalent a &lt;br /&gt;
 portatil$ssh 192.168.1.130&lt;br /&gt;
&lt;br /&gt;
recordem que en aquest cas particular no fiquem login i password perquè hi ha una autentificació de clau pública i privada. Si no, s'hauria de posar&lt;br /&gt;
  portatil$rlogin joan@192.168.1.130&lt;br /&gt;
i demanaria el password&lt;br /&gt;
&lt;br /&gt;
==rcp==&lt;br /&gt;
la formca correcta de fer rcp és scp, doncs ho fa de forma segura.&lt;br /&gt;
 portatil$ scp hola.sql 192.168.1.130:hola_servidor.sql&lt;br /&gt;
També hi ha la possibilitat de copiar fitxers d'un ordinador remot a un altre ordinador remot.&lt;br /&gt;
 portatil$ scp [[user@]host1:]file1 [[user@]host2:]file2&lt;br /&gt;
&lt;br /&gt;
Com sempre, la gràcia perquè no demani login i password (i així poder automatitzar aquestes tasques en els scripts) és  instal.lar una clau pública en els servidors, com està explicat en l'article de SSH&lt;/div&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
</feed>