Granary / granary

Dynamic binary translation framework for instrumenting the Linux kernel and its modules
Other
76 stars 6 forks source link

Problem: Physical host can not connect to VM in Qemu through ssh. #14

Closed renzhengeek closed 10 years ago

renzhengeek commented 10 years ago

According to ssh-config-convenience.md in doc dirctory: fisrtly, I set sshd port 5556 in VM; a) make hostname equal VM ip:10.0.2.15 in ~/.ssh/config file, ssh cannot connect to VM. b)howere, make hostname equal localhost, ssh actually connect to my physical host.

But, after config ssh in the VM, ssh can connect to physical host.

anyone who konw the reason?thanks!

pgoodman commented 10 years ago

If a line is commented out in the the doc then try to also not include it :-P What I use to connect to the host from within the VM is 10.0.2.2.

The ssh config conveniences are meant for the host, not the guest / VM. That is, in the example, from within the host, one does "ssh root@deb7vm" to connect to the VM. The script fastload.py also picks up on this, when you specify "deb7vm" through "--remote".

Does this work?

Best Regards,

Peter Goodman, http://www.petergoodman.me 65 High Park Ave., Toronto, Ontario M6P 2R7

On 25 February 2014 22:27, Ren Zhen notifications@github.com wrote:

According to ssh-config-convenience.md in doc dirctory: fisrtly, I set sshd port 5556 in VM; a) make hostname equal VM ip:10.0.2.15 in ~/.ssh/config file, ssh cannot connect to VM. b)howere, make hostname equal localhost, ssh actually connect to my physical host.

But, after config ssh in the VM, ssh can connect to physical host.

anyone who konw the reason?thanks!

Reply to this email directly or view it on GitHubhttps://github.com/Granary/granary/issues/14 .

pgoodman commented 10 years ago

Within your VM (the gues), you can ssh to your physical machine (the host) with 10.0.2.2.

Just copy & paste what is shown in the docs to the config file on your host (your physical machine). In the guest (your VM), follow these guidelines to make it so that the "root" user can login: http://askubuntu.com/questions/44418/how-to-enable-root-login.

Finally, within the host, try to ssh into your guest using "ssh root@deb7vm", where "deb7vm" is the host name given to your vm in the ssh config file (you can make this name whatever you want).

Best Regards,

Peter Goodman, http://www.petergoodman.me 65 High Park Ave., Toronto, Ontario M6P 2R7

On 25 February 2014 23:28, Ren Zhen notifications@github.com wrote:

It seems there is no rout to my VM whose ip is 10.0.2.15. even when I $ssh root@10.0.2.15, it(physical host ssh client) still can not connect VM sshd. so I think it not ~/.ssh/config's problem.

Reply to this email directly or view it on GitHubhttps://github.com/Granary/granary/issues/14#issuecomment-36089845 .

renzhengeek commented 10 years ago

thank you for detailed help.

It is ok ssh from host to VM with 10.0.2.2.

Yes,I do copy & paste what is shown in the docs to the config file on my host. the part of config is below: { Host deb7vm User root Hostname localhost '#Hostname 10.0.2.15 Port 5556 } I know deb7vm is VM's name, Hostname should be VM's IP, and Port is sshd's port in VM. here,I use a normal user "renzhen" in VM. what confused me is that Hostname whose localhost refer host (127.0.0.1), not VM. So, I tried localhost and 10.0.2.15,both cannot works.

renzhengeek commented 10 years ago

In VM,I use ifconfig look its ip is truely 10.0.2.15. Then, In host, I use ping 10.0.2.15 to test, just show data all lost.

pgoodman commented 10 years ago

Yes I see the same thing when I do ifconfig within the VM as well. Try doing this within the vm: "ssh renzhen@10.0.2.2" (assuming that renzhen is the user on your physical machine as well).

In the ssh config file, I think all you need to put is localhost, and not 10.0.2.15. I dunno why but if it works then just do it. :-P

Best Regards,

Peter Goodman, http://www.petergoodman.me 65 High Park Ave., Toronto, Ontario M6P 2R7

On 26 February 2014 00:51, Ren Zhen notifications@github.com wrote:

In VM,I use ifconfig look its ip is truely 10.0.2.15. Then, In host, I use ping 10.0.2.15 to test, just show data all lost.

Reply to this email directly or view it on GitHubhttps://github.com/Granary/granary/issues/14#issuecomment-36093242 .

renzhengeek commented 10 years ago

aha, it works! it is because I may not understand much things in docs.sorry.

befor I lanched VM with command-line, this time I use shell to lanch. eveverytime before when execute $ssh-copy-id -i ~/.ssh/id_rsa.pub deb7vm it connected to my host itselft,which I thought it should connect to VM. but when I use $ssh deb7vm it ssh to VM successfully. thanks a lot.