Setting up SSH on the system simulator

From Cellbe

(Difference between revisions)
Line 36: Line 36:
</pre>
</pre>
Take note of what <tt>snif</tt> outputs (the name of the interface just created - tipically tap0), you will need it later.
Take note of what <tt>snif</tt> outputs (the name of the interface just created - tipically tap0), you will need it later.
-
 
+
<pre>
 +
# ifconfig tap0 172.20.0.1 netmask 255.255.255.0 up
 +
</pre>
===Setting up the simulator===
===Setting up the simulator===
The first thing to do is to setup the bogus network on the simulator. In your sandbox directory (if you don't have one, create it - e.g. <tt>~/sandbox</tt>) edit the file <tt>.systemsim.tcl</tt> - if you don't have one yet, copy the one <tt>systemsim</tt> uses by default, found in <tt>/opt/ibm/systemsim-cell/run/cell/linux/.systemsim.tcl</tt>.
The first thing to do is to setup the bogus network on the simulator. In your sandbox directory (if you don't have one, create it - e.g. <tt>~/sandbox</tt>) edit the file <tt>.systemsim.tcl</tt> - if you don't have one yet, copy the one <tt>systemsim</tt> uses by default, found in <tt>/opt/ibm/systemsim-cell/run/cell/linux/.systemsim.tcl</tt>.

Revision as of 14:29, 24 July 2007

This article explains how to setup ssh your host and your simulated environment. At the end, you will be able to run ssh to connect to your host from the simulated environment, and viceversa. This information can be (partially) found on the IBM system simulator user guide (on a default sdk installation, this can be found on /opt/ibm/systemsim-cell/doc/SystemSim.Users.guide)

The following conventions will be used:

  • $ your user bash prompt in the host environment
  • # your root bash prompt in the host environment
  • [root@(none) ~]# The bash prompt in the simulated environment
  • % The TCL simulator shell.

Contents

Environment

This applies to the last SDK version (2.1), and assumes it is installed on a Fedora Core 6 (FC6) host. Root access on the host is required.

Setting up the TUN/TAP interfaces on the host

Make sure the device /dev/net/tun exists on the host. On a default FC6 installation it does. By default, tap interfaces are usable only by the root user. If you want to start the simulator as a normal user, you have to make them usable by normal users. To do it, issue

$ su -

You will be asked for the root password. Create and edit the file /etc/udev/rules.d/systemsim.rules and write in

KERNEL=="tun", MODE="0666"

Reboot your host to make your changes effective.

The user who runs the simulator has to create a tap interface with the command snif (it should be installed with the sdk). To create an interface with snif, just run

$ snif -c -u uid ip_address
  • uid should be set to the numerical user id of the user who runs the simulator (you can look for it in /etc/passwd, or just run the command id at the host command prompt)
  • ip_address should be set to an ip address that it's on the same network of the eth0 interface of the simulator. By default the ip address of eth0 on the simulator is 172.20.0.2, so you can set the ip address to 172.20.0.XXX

example:

$ id
uid=1005(ale) gid=1005(ale) groups=1005(ale) context=user_u:system_r:unconfined_t

$ snif -c -u 1005 172.20.0.1
tap0

Take note of what snif outputs (the name of the interface just created - tipically tap0), you will need it later.

# ifconfig tap0 172.20.0.1 netmask 255.255.255.0 up

Setting up the simulator

The first thing to do is to setup the bogus network on the simulator. In your sandbox directory (if you don't have one, create it - e.g. ~/sandbox) edit the file .systemsim.tcl - if you don't have one yet, copy the one systemsim uses by default, found in /opt/ibm/systemsim-cell/run/cell/linux/.systemsim.tcl. At the end of the file, put this line:

mysim bogus net init 0 00:50:56:C0:00:01 tap0 0 0

Substitute 00:50:56:C0:00:01 with a dummy mac address of your choice (tipically, one not used in your network), and substitute tap0 with the interface you created with snif.

Now, you should be able to connect from the simulator to the host with ssh, but not viceversa. As a quick and dirty hack, we setup the simulator disk to be persistent, and start sshd in the simulated environment from root's .bashrc (I'll explain why in the next section). In your .systemsim.tcl file, change the line

mysim bogus disk init 0 $sysrootfile newcow sysroot_disk.cow 1024

to

mysim bogus disk init 0 $sysrootfile cow sysroot_disk.cow 1024

Save the changes and run the simulator from the sandbox directory.

About the persistent disk

Make sure you sync the bogus disk before shutting down the simulator to keep the disk in a consistent state! You can do this by typing

% mysim bogus disk sync 0

at the simulator TCL shell prompt.

Setting up the simulated environment

Now the dirty hack: to make sshd start on boot, edit root's .bashrc on the simulated environment:

[root@(none) ~]# vi .bashrc

and at the end of the file add this line:

/etc/init.d/sshd start

then save and exit, and source your .bashrc:

[root@(none) ~]# source .bashrc

This surely is a dirty way to make it start sshd on boot, but we didn't find a better way (chkconfig sshd on did not work). Now you should be able to ssh to the simulated environment, running

$ ssh root@172.20.0.2

at the bash prompt on your host. But there's a problem: in the simulated environment changing the password with passwd gave an error message. We solved it appending our public keys in the simulated environment: At your host prompt, generate your public keys:

$ ssh-keygen -t rsa

Now, from the simulated environment, copy your key file, and then append it to your authorized_keys file.

[root@(none) ~]# scp user@host:~/.ssh/id_rsa.pub .
[root@(none) ~]# cat id_rsa.pub >> ~/.ssh/authorized_keys

Substitute user with your user name on the host of course, and do this for each user you want to have access on your simulated machine. To make this changes persistent, sync your simulated disk: press Ctrl-c in the simulator tcl shell window to obtain the prompt, and then type:

% mysim bogus disk sync 0

You can resume the simulator typing

% mysim go

Now, ssh should work: at your host prompt, type

$ ssh root@172.20.0.2

If everything went well, it should ask you no password, and take you to the simulator prompt.

laynor 07:40, 4 July 2007 (EDT)

Personal tools