LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-27-2011, 12:18 AM   #1
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Rep: Reputation: 3
Question Cannot ssh guest OS from host


Hello everyone,
So I'm a Linux newbie. I'm trying to learn ssh ,ftp, telnet and other stuffs after introducing myself to some basic commands.But my problem is that i have only one laptop , so i decided to give a go to VirtualBox .Ok lets cut this crap and head to the main problem...
Host = Ubuntu 11.04
Guest = Arch 2.6.33
VM= VirtualBox 4.0.10
I have installed openssh in both machines.I followed the this link
http://www.wiredrevolution.com/virtu...-and-guest-vms
So now this is what i can do,
1- I can ping and ssh from guest to host
2- I can ping guest from host but cannot ssh.(i need to mention that i used
Quote:
ifconfig eth1 192.168.56.2 netmask 255.255.255.0
command in guest ) And here is the error when i try to ssh guest OS
Quote:
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.56.2 [192.168.56.2] port 22.
debug1: connect to address 192.168.56.2 port 22: Connection refused
ssh: connect to host 192.168.56.2 port 22: Connection refused
3- Checked firewall in Ubuntu 11.04 it says it's inactive and i assume there's no default firewall in Arch(correct me if i am wrong)
Do i need to change something in hosts.deny or hosts.allow in guest or host os(I think it's related to something tcp wrappers but i don't have any idea). I don't know what to do :|
Any help will be appreciated TIA
 
Old 09-27-2011, 01:01 AM   #2
indeliblestamp
Member
 
Registered: Feb 2006
Distribution: Fedora
Posts: 341
Blog Entries: 3

Rep: Reputation: 40
Is an ssh server running on the guest? do an 'ssh localhost' on it to see if that works first.
 
1 members found this post helpful.
Old 09-27-2011, 01:34 AM   #3
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Original Poster
Rep: Reputation: 3
oops!
Quote:
ssh: connect to host localhost port 22: connection refused
I thought checking sshd was enough, my bad...
How can i process now (Ok Gonna google it)
Thanks for your reply

Last edited by konsolelover; 09-27-2011 at 01:42 AM. Reason: i'm stupid
 
Old 09-27-2011, 02:08 AM   #4
indeliblestamp
Member
 
Registered: Feb 2006
Distribution: Fedora
Posts: 341
Blog Entries: 3

Rep: Reputation: 40
Arch has an excellent wiki. Here is their SSH page: https://wiki.archlinux.org/index.php/Secure_Shell (you'll need just section 1 to get started).
 
Old 09-27-2011, 02:42 AM   #5
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Original Poster
Rep: Reputation: 3
I'm clueless
Quote:
rc.d start sshd
bash : rc.d : command not found
 
Old 09-27-2011, 02:53 AM   #6
Chenchu
Member
 
Registered: Nov 2009
Location: Mars
Distribution: CentOS
Posts: 50

Rep: Reputation: 20
Are you running the command as root user?
 
Old 09-27-2011, 03:03 AM   #7
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
(removed; I'm stupid)

EDIT: Actually, maybe I can still help (): try just directly invoking the daemon script with /etc/rc.d/sshd start. rc.d, AFAIK, is mostly just a proxy/enhancement to that functionality.

…and yes, make sure you're root as well.

EDIT++: pgrep sshd to see if it's already running.

Last edited by MrCode; 09-27-2011 at 03:11 AM. Reason: …gotta learn to READ… :p
 
1 members found this post helpful.
Old 09-27-2011, 03:53 AM   #8
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Original Poster
Rep: Reputation: 3
Quote:
Are you running the command as root user?
sudo rc.d start sshd
Quote:
sudo : rc.d : command not found
Also tried by switching to root user....
 
Old 09-27-2011, 03:58 AM   #9
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Original Poster
Rep: Reputation: 3
Wink

Quote:
Originally Posted by MrCode View Post
(removed; I'm stupid)

EDIT: Actually, maybe I can still help (): try just directly invoking the daemon script with /etc/rc.d/sshd start. rc.d, AFAIK, is mostly just a proxy/enhancement to that functionality.

…and yes, make sure you're root as well.

EDIT++: pgrep sshd to see if it's already running.
/etc/rc.d/sshd start worked
but when i had tried
Quote:
ps aux| grep sshd
it showed that it's running and
Quote:
pgrep sshd
didn't. Why??
BTW thanks for your response
EDIT: So now i can access my guest OS using eth1 interface but when i try to access guest OS using ip of eth0 interface neither i can ping nor ssh.It means that it won't be accessible from internet (other than host OS and other guests).

Last edited by konsolelover; 09-27-2011 at 04:37 AM.
 
Old 09-27-2011, 05:01 AM   #10
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
Quote:
EDIT: So now i can access my guest OS using eth1 interface but when i try to access guest OS using ip of eth0 interface neither i can ping nor ssh.It means that it won't be accessible from internet (other than host OS and other guests).
You should be able to work around this by allowing internet access from the guest through your host's network interface.

Here's what I do if I want a virtual machine to be accessible through SSH while still having internet access:


1. Set up iptables/IP forwarding on the host:

Code:
iptables -t nat -A POSTROUTING -o <host network interface> -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
(don't forget to (re)start iptables )

2. Set the default gateway/DNS nameservers on the guest: point the gateway to the IP of the host virtual network interface (typically vboxnet0), and set the DNS servers to be identical to those on the host. I usually stick these lines in /etc/rc.local (or whatever the equivalent init script is in whatever distro/OS it is that I'm messing with ):

Code:
echo "nameserver <ISP DNS server IP, or maybe router IP>" > /etc/resolv.conf
route add default gw <IP of virtual host interface>
I don't guarantee that this exact setup will work for you, but it works for me, so… :-\

EDIT: If you need more details on this, the Arch Wiki delivers. Most of the information there should apply just as well to a "share" between a host and a VM as it does a network between two real machines.

Last edited by MrCode; 09-27-2011 at 05:04 AM.
 
Old 09-27-2011, 08:13 AM   #11
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Original Poster
Rep: Reputation: 3
Hmmm gotta learn iptables next. Thanks for your replies and thread gets the solved prefix. ;-)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VirtualBox: Slackware64 host and guest; NFS mount from host fails catkin Linux - Virtualization and Cloud 0 11-15-2010 06:54 AM
Host and guest divyashree Linux - Virtualization and Cloud 1 10-15-2010 07:34 AM
[SOLVED] Interaction between a Host OS and a Guest OS Hi_This_is_Dev Linux - Networking 15 09-03-2010 06:06 AM
KVM: run guest commands from host without SSH s7upify Linux - Virtualization and Cloud 1 08-16-2010 02:29 PM
networking between host and guest divyashree Linux - Networking 3 03-06-2009 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration