Setting up SSH on the system simulator
From Cellbe
(fSCQ2E Thanks a lot for the article. Awesome.) |
(Really appreciate you sharing this post.Thanks Again. Will read on...) |
||
Line 11: | Line 11: | ||
fSCQ2E Thanks a lot for the article. Awesome. | fSCQ2E Thanks a lot for the article. Awesome. | ||
- | + | Really appreciate you sharing this post.Thanks Again. Will read on... | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
===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 22:34, 20 March 2012
reldomacc 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.
fSCQ2E Thanks a lot for the article. Awesome.
Really appreciate you sharing this post.Thanks Again. Will read on...
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)