ssh to freebsd

A

Anonymous

Guest
I try to ssh into FreeBSD, but i get a:
Code:
ssh: connect to host 192.168.x.x port 22: Connection refused
I checked the handbook and some other sites, from what i can see the settings in /etc/ssh/sshd_config seem to be ok. What might i be missing? Thanks
 
Is sshd enabled?

In /etc/rc.conf:
Code:
sshd_enable="YES"

Is sshd started?
Code:
/etc/rc.d/sshd status
That should return the PID that sshd is running as.

Try [cmd=]sockstat -l4[/cmd] (that's a lower-case "L") and you should see sshd listening on port 22.

Report back your results.
 
It is enabled in rc.conf.

/etc/rc.d/sshd status gives:
Code:
sshd is running as pid 1894

sockstat -l4
Code:
root sshd 1894 3 tcp4 10.1.1.1:22 *:*

In this case it is running in VirtualBox, but i had the same problem from PC to PC.
I try to do it with password authentication.
 
Is target machine/virtual machine accesible with ping?

You can rise logging level of runnig sshd
sshd_config()
LogLevel

Gives the verbosity level that is used when logging messages from sshd(8). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO.

DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of debugging output. Logging with a DEBUG level violates the privacy of users and is not recommended.

Are those packets even coming? Try it with tcpdump().
# tcpdump -i [i]name_of_interaface[/i] host [i]ip_from_which_we_are_connecting[/i] and port ssh

May looks strange written as is, so what isn't in italics is part of command.
 
jalu said:
I try to ssh into FreeBSD, but i get a:
Code:
ssh: connect to host 192.168.x.x port 22: Connection refused

...

sockstat -l4
Code:
root sshd 1894 3 tcp4 10.1.1.1:22 *:*

See any problem with this picture? ;)

I'm not a Virtualbox expert, but presumably you expect it to be providing NAT for the virtualized system? Or maybe you meant to bridge its interface with the host system's interface..?
 
anomie said:
See any problem with this picture? ;)

I'm not a Virtualbox expert, but presumably you expect it to be providing NAT for the virtualized system? Or maybe you meant to bridge its interface with the host system's interface..?

There is usually something "just making it work", NAT or bridging by default installation, but personally not sure about VirtualBox now.

In fact, jalu is connecting somewhere, either to his virtual machine via NAT/bridge or to some diferent machine, which doesn't allow access or listen on specified port. In case, that there wouldn't be network connection with given IP address, he will receive Connection timeout instead of Connection refused error.
 
ondra_knezour: Thanks. I may ping. I will check tcpdump and more verbosity.

anomie: I have seen the problem *after* i ran the command 'sockstat'. I was not sure if i understood it correct.
Sorry, i can't explain VirtualBox other than with an example from the LInux-world:
If i use Linux as a guest i get one address for NAT, which connects to the internet. That is automatically (Linux-speak is eth0 for that one).
For that one the IP is similar to 10.1.1.1
I set a second network-adapter in virtualbox-settings, called host-only (LInux-speak is eth1). With that one i may ssh/rsync/etc from guest to host and vice versa. The IP for that one is 192.168.56.101 (for the guest) and 192.168.56.1 (for the host).

Now: why em1 is getting addressed as 10.1.1.1 (instead of 192.168.56.191) is beyond me.
 
jalu said:
Now: why em1 is getting addressed as 10.1.1.1 (instead of 192.168.56.191) is beyond me.
The order of interface names may be different. Check em0.
 
Don't use NAT networking in VirtualBox. Use bridged networking.

That way, your VMs appear just like every other computer on the network, and they are part of the same subnet as all the other computers on the network.
 
phoenix said:
Don't use NAT networking in VirtualBox. Use bridged networking.

That way, your VMs appear just like every other computer on the network, and they are part of the same subnet as all the other computers on the network.
I do it in VirtualBox to learn about networking. I am much of a beginner. I was adviced to make use of "NAT" and "host-only" at forums.virtualbox.org. It did give me a possibility to train a bit (ssh, scp, rsync, sshfs...)

You got a link about how to set it up with bridged-networking?
Thanks, i will look into that.
 
jalu said:
I do it in VirtualBox to learn about networking. I am much of a beginner. I was adviced to make use of "NAT" and "host-only" at forums.virtualbox.org. It did give me a possibility to train a bit (ssh, scp, rsync, sshfs...)

NAT will work if you set Virtualbox to port-forward incoming connections. http://sk.c-wd.net/wp/2008/01/05/virtualbox-port-forwarding-with-linux-host/ shows how.

You got a link about how to set it up with bridged-networking?

Just set it to bridged mode in the Virtualbox GUI. With bridged mode, your VM doesn't use the Virtualbox DHCP or NAT. It acts like it's just another computer plugged directly into the network.
 
Yes, the problem was that simple. Once i was able to set the connection for the guest to the correct IP it did work flawless. Thanks for the help.
I can't figure out how to set a thread as solved. How does that work? Thanks in advance
 
Back
Top