common issue : ssh: connect to host 10.0.2.15 port 22: Connection refused
up vote
2
down vote
favorite
I am using VirtualBox on Windows 10 (host) to create two virtual machines (Guest DT
and Guest S
). Can I SSH from Guest DT
to the Guest S
?
Guest DT
is Ubuntu Desktop 18.04.
Guest S
is running Ubuntu Server 18.04.- VirtualBox Terminology
I am inexperienced with SSH. I have googled and read answers to the 'similar questions' on this site.
Error
On Guest DT
, I do this:
$ ssh test@10.0.2.15
ssh: connect to host 10.0.2.15 port 22: Connection refused
Note:
- I can successfully ping 10.0.2.15
test
is my username on theGuest S
.
Environment Setup
On Guest DT
:
$ ssh-keygen
$ cat ~/.ssh/id_rsa.pub
ssh-rsa <a very long key> neil@neil-VirtualBox
On Guest S
:
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
$ echo "ssh-rsa <a very long key> neil@neil-VirtualBox" > ~/.ssh/authorized_keys
$ /etc/init.d/ssh restart
On Guest S
:
test@server01:~$ service sshd status
ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-15 02:05:04 UTC; 1h 16min ago
Process: 903 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 906 (sshd)
Tasks: 1 (limit: 2317)
CGroup: /system.slice/ssh.service
└─906 /usr/sbin/sshd -D
Jun 15 02:05:04 server01 systemd[1]: Starting OpenBSD Secure Shell server...
Jun 15 02:05:04 server01 sshd[906]: Server listening on 0.0.0.0 port 22.
Jun 15 02:05:04 server01 sshd[906]: Server listening on :: port 22.
Jun 15 02:05:04 server01 systemd[1]: Started OpenBSD Secure Shell server.
$ sudo ufw status
[sudo] password for test:
Status: inactive
/etc/ssh/sshd_config contains :
#PubkeyAuthentication yes
server virtualbox ssh
|
show 1 more comment
up vote
2
down vote
favorite
I am using VirtualBox on Windows 10 (host) to create two virtual machines (Guest DT
and Guest S
). Can I SSH from Guest DT
to the Guest S
?
Guest DT
is Ubuntu Desktop 18.04.
Guest S
is running Ubuntu Server 18.04.- VirtualBox Terminology
I am inexperienced with SSH. I have googled and read answers to the 'similar questions' on this site.
Error
On Guest DT
, I do this:
$ ssh test@10.0.2.15
ssh: connect to host 10.0.2.15 port 22: Connection refused
Note:
- I can successfully ping 10.0.2.15
test
is my username on theGuest S
.
Environment Setup
On Guest DT
:
$ ssh-keygen
$ cat ~/.ssh/id_rsa.pub
ssh-rsa <a very long key> neil@neil-VirtualBox
On Guest S
:
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
$ echo "ssh-rsa <a very long key> neil@neil-VirtualBox" > ~/.ssh/authorized_keys
$ /etc/init.d/ssh restart
On Guest S
:
test@server01:~$ service sshd status
ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-15 02:05:04 UTC; 1h 16min ago
Process: 903 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 906 (sshd)
Tasks: 1 (limit: 2317)
CGroup: /system.slice/ssh.service
└─906 /usr/sbin/sshd -D
Jun 15 02:05:04 server01 systemd[1]: Starting OpenBSD Secure Shell server...
Jun 15 02:05:04 server01 sshd[906]: Server listening on 0.0.0.0 port 22.
Jun 15 02:05:04 server01 sshd[906]: Server listening on :: port 22.
Jun 15 02:05:04 server01 systemd[1]: Started OpenBSD Secure Shell server.
$ sudo ufw status
[sudo] password for test:
Status: inactive
/etc/ssh/sshd_config contains :
#PubkeyAuthentication yes
server virtualbox ssh
Please runsudo ufw status
, and edit your question to add the output from that command.
– vidarlo
Jun 15 at 4:50
make surePubkeyAuthentication
is set toyes
in/etc/ssh/sshd_config
– RoVo
Jun 15 at 9:12
Are the VM's networks configured as "NAT" or "NAT Network"?
– steeldriver
Jun 15 at 14:53
Um,#PubkeyAuthentication yes
is commented out, you need to remove the hash. I'd have tested with a simple password first. Presumably the ssh traffic passes through the host and could be blocked by its firewall?
– pbhj
Jun 15 at 21:59
Thanks for the responses. No success yet.
– Neil E
Jun 15 at 23:33
|
show 1 more comment
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am using VirtualBox on Windows 10 (host) to create two virtual machines (Guest DT
and Guest S
). Can I SSH from Guest DT
to the Guest S
?
Guest DT
is Ubuntu Desktop 18.04.
Guest S
is running Ubuntu Server 18.04.- VirtualBox Terminology
I am inexperienced with SSH. I have googled and read answers to the 'similar questions' on this site.
Error
On Guest DT
, I do this:
$ ssh test@10.0.2.15
ssh: connect to host 10.0.2.15 port 22: Connection refused
Note:
- I can successfully ping 10.0.2.15
test
is my username on theGuest S
.
Environment Setup
On Guest DT
:
$ ssh-keygen
$ cat ~/.ssh/id_rsa.pub
ssh-rsa <a very long key> neil@neil-VirtualBox
On Guest S
:
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
$ echo "ssh-rsa <a very long key> neil@neil-VirtualBox" > ~/.ssh/authorized_keys
$ /etc/init.d/ssh restart
On Guest S
:
test@server01:~$ service sshd status
ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-15 02:05:04 UTC; 1h 16min ago
Process: 903 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 906 (sshd)
Tasks: 1 (limit: 2317)
CGroup: /system.slice/ssh.service
└─906 /usr/sbin/sshd -D
Jun 15 02:05:04 server01 systemd[1]: Starting OpenBSD Secure Shell server...
Jun 15 02:05:04 server01 sshd[906]: Server listening on 0.0.0.0 port 22.
Jun 15 02:05:04 server01 sshd[906]: Server listening on :: port 22.
Jun 15 02:05:04 server01 systemd[1]: Started OpenBSD Secure Shell server.
$ sudo ufw status
[sudo] password for test:
Status: inactive
/etc/ssh/sshd_config contains :
#PubkeyAuthentication yes
server virtualbox ssh
I am using VirtualBox on Windows 10 (host) to create two virtual machines (Guest DT
and Guest S
). Can I SSH from Guest DT
to the Guest S
?
Guest DT
is Ubuntu Desktop 18.04.
Guest S
is running Ubuntu Server 18.04.- VirtualBox Terminology
I am inexperienced with SSH. I have googled and read answers to the 'similar questions' on this site.
Error
On Guest DT
, I do this:
$ ssh test@10.0.2.15
ssh: connect to host 10.0.2.15 port 22: Connection refused
Note:
- I can successfully ping 10.0.2.15
test
is my username on theGuest S
.
Environment Setup
On Guest DT
:
$ ssh-keygen
$ cat ~/.ssh/id_rsa.pub
ssh-rsa <a very long key> neil@neil-VirtualBox
On Guest S
:
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
$ echo "ssh-rsa <a very long key> neil@neil-VirtualBox" > ~/.ssh/authorized_keys
$ /etc/init.d/ssh restart
On Guest S
:
test@server01:~$ service sshd status
ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-15 02:05:04 UTC; 1h 16min ago
Process: 903 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 906 (sshd)
Tasks: 1 (limit: 2317)
CGroup: /system.slice/ssh.service
└─906 /usr/sbin/sshd -D
Jun 15 02:05:04 server01 systemd[1]: Starting OpenBSD Secure Shell server...
Jun 15 02:05:04 server01 sshd[906]: Server listening on 0.0.0.0 port 22.
Jun 15 02:05:04 server01 sshd[906]: Server listening on :: port 22.
Jun 15 02:05:04 server01 systemd[1]: Started OpenBSD Secure Shell server.
$ sudo ufw status
[sudo] password for test:
Status: inactive
/etc/ssh/sshd_config contains :
#PubkeyAuthentication yes
server virtualbox ssh
server virtualbox ssh
edited Jun 15 at 9:25
asked Jun 15 at 3:48
Neil E
134
134
Please runsudo ufw status
, and edit your question to add the output from that command.
– vidarlo
Jun 15 at 4:50
make surePubkeyAuthentication
is set toyes
in/etc/ssh/sshd_config
– RoVo
Jun 15 at 9:12
Are the VM's networks configured as "NAT" or "NAT Network"?
– steeldriver
Jun 15 at 14:53
Um,#PubkeyAuthentication yes
is commented out, you need to remove the hash. I'd have tested with a simple password first. Presumably the ssh traffic passes through the host and could be blocked by its firewall?
– pbhj
Jun 15 at 21:59
Thanks for the responses. No success yet.
– Neil E
Jun 15 at 23:33
|
show 1 more comment
Please runsudo ufw status
, and edit your question to add the output from that command.
– vidarlo
Jun 15 at 4:50
make surePubkeyAuthentication
is set toyes
in/etc/ssh/sshd_config
– RoVo
Jun 15 at 9:12
Are the VM's networks configured as "NAT" or "NAT Network"?
– steeldriver
Jun 15 at 14:53
Um,#PubkeyAuthentication yes
is commented out, you need to remove the hash. I'd have tested with a simple password first. Presumably the ssh traffic passes through the host and could be blocked by its firewall?
– pbhj
Jun 15 at 21:59
Thanks for the responses. No success yet.
– Neil E
Jun 15 at 23:33
Please run
sudo ufw status
, and edit your question to add the output from that command.– vidarlo
Jun 15 at 4:50
Please run
sudo ufw status
, and edit your question to add the output from that command.– vidarlo
Jun 15 at 4:50
make sure
PubkeyAuthentication
is set to yes
in /etc/ssh/sshd_config
– RoVo
Jun 15 at 9:12
make sure
PubkeyAuthentication
is set to yes
in /etc/ssh/sshd_config
– RoVo
Jun 15 at 9:12
Are the VM's networks configured as "NAT" or "NAT Network"?
– steeldriver
Jun 15 at 14:53
Are the VM's networks configured as "NAT" or "NAT Network"?
– steeldriver
Jun 15 at 14:53
Um,
#PubkeyAuthentication yes
is commented out, you need to remove the hash. I'd have tested with a simple password first. Presumably the ssh traffic passes through the host and could be blocked by its firewall?– pbhj
Jun 15 at 21:59
Um,
#PubkeyAuthentication yes
is commented out, you need to remove the hash. I'd have tested with a simple password first. Presumably the ssh traffic passes through the host and could be blocked by its firewall?– pbhj
Jun 15 at 21:59
Thanks for the responses. No success yet.
– Neil E
Jun 15 at 23:33
Thanks for the responses. No success yet.
– Neil E
Jun 15 at 23:33
|
show 1 more comment
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
I think the default networking setup for VirtualBox guest is NAT
and is not really intended to achieve this type of networking communication; but based on old posts may be possible by forwarding a non-system port to a Guest port and using the default loopback IP address to reach the Guest. 10.0.2.2 is default loopback.
Setup Networking
However, the easiest is to ensure you choose the correct networking for each of the Guests. Shutdown you guest machines, then in VirtualBox edit the Networking mode appropriate for your needs (note grid).
Using Default NAT Network
Using NAT, VirtualBox uses a special IP 10.0.2.2 as a loopback (at least I think this is still true). Therefore ports forwarded from loopback are available to all guests. I think you should be able to take advantage of this. To communicate using a NAT network, will require one of the following:
Using VBoxManage, setup NAT Forwarding of a non-system port (1024–65535) to a lower system port (< 1024).
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Guest S
IP address of10.0.2.15
, per the question.
Configure port forwarding on the Virtualbox Host, run:
VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
All TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). The name guestssh is purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the network card, like in other parts of VBoxManage.
Check the added rule:
VBoxManage showvminfo myserver | grep 'Rule'
Connect to
Guest Server
via host loopback mapping and port-forwarding forGuest S
neil@neil-VirtualBox$ ssh -p 2222 test@10.0.2.2
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Alternative: change (Guest S) /etc/sshd_config to listen on a
non-system port (> 1024). Then reload ssh.
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
add a comment |
up vote
0
down vote
Simply remove all ECDSA fingerprint keys (probably SHA256) contained within known-hosts directory.
- Run
vi ~/.ssh/known_hosts
- Delete all keys associated with subject IP-address within the known_hosts file.
- Enter "Esc"-key then "Shift"-key + ":" + "x"
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1046736%2fcommon-issue-ssh-connect-to-host-10-0-2-15-port-22-connection-refused%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I think the default networking setup for VirtualBox guest is NAT
and is not really intended to achieve this type of networking communication; but based on old posts may be possible by forwarding a non-system port to a Guest port and using the default loopback IP address to reach the Guest. 10.0.2.2 is default loopback.
Setup Networking
However, the easiest is to ensure you choose the correct networking for each of the Guests. Shutdown you guest machines, then in VirtualBox edit the Networking mode appropriate for your needs (note grid).
Using Default NAT Network
Using NAT, VirtualBox uses a special IP 10.0.2.2 as a loopback (at least I think this is still true). Therefore ports forwarded from loopback are available to all guests. I think you should be able to take advantage of this. To communicate using a NAT network, will require one of the following:
Using VBoxManage, setup NAT Forwarding of a non-system port (1024–65535) to a lower system port (< 1024).
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Guest S
IP address of10.0.2.15
, per the question.
Configure port forwarding on the Virtualbox Host, run:
VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
All TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). The name guestssh is purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the network card, like in other parts of VBoxManage.
Check the added rule:
VBoxManage showvminfo myserver | grep 'Rule'
Connect to
Guest Server
via host loopback mapping and port-forwarding forGuest S
neil@neil-VirtualBox$ ssh -p 2222 test@10.0.2.2
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Alternative: change (Guest S) /etc/sshd_config to listen on a
non-system port (> 1024). Then reload ssh.
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
add a comment |
up vote
0
down vote
accepted
I think the default networking setup for VirtualBox guest is NAT
and is not really intended to achieve this type of networking communication; but based on old posts may be possible by forwarding a non-system port to a Guest port and using the default loopback IP address to reach the Guest. 10.0.2.2 is default loopback.
Setup Networking
However, the easiest is to ensure you choose the correct networking for each of the Guests. Shutdown you guest machines, then in VirtualBox edit the Networking mode appropriate for your needs (note grid).
Using Default NAT Network
Using NAT, VirtualBox uses a special IP 10.0.2.2 as a loopback (at least I think this is still true). Therefore ports forwarded from loopback are available to all guests. I think you should be able to take advantage of this. To communicate using a NAT network, will require one of the following:
Using VBoxManage, setup NAT Forwarding of a non-system port (1024–65535) to a lower system port (< 1024).
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Guest S
IP address of10.0.2.15
, per the question.
Configure port forwarding on the Virtualbox Host, run:
VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
All TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). The name guestssh is purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the network card, like in other parts of VBoxManage.
Check the added rule:
VBoxManage showvminfo myserver | grep 'Rule'
Connect to
Guest Server
via host loopback mapping and port-forwarding forGuest S
neil@neil-VirtualBox$ ssh -p 2222 test@10.0.2.2
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Alternative: change (Guest S) /etc/sshd_config to listen on a
non-system port (> 1024). Then reload ssh.
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I think the default networking setup for VirtualBox guest is NAT
and is not really intended to achieve this type of networking communication; but based on old posts may be possible by forwarding a non-system port to a Guest port and using the default loopback IP address to reach the Guest. 10.0.2.2 is default loopback.
Setup Networking
However, the easiest is to ensure you choose the correct networking for each of the Guests. Shutdown you guest machines, then in VirtualBox edit the Networking mode appropriate for your needs (note grid).
Using Default NAT Network
Using NAT, VirtualBox uses a special IP 10.0.2.2 as a loopback (at least I think this is still true). Therefore ports forwarded from loopback are available to all guests. I think you should be able to take advantage of this. To communicate using a NAT network, will require one of the following:
Using VBoxManage, setup NAT Forwarding of a non-system port (1024–65535) to a lower system port (< 1024).
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Guest S
IP address of10.0.2.15
, per the question.
Configure port forwarding on the Virtualbox Host, run:
VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
All TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). The name guestssh is purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the network card, like in other parts of VBoxManage.
Check the added rule:
VBoxManage showvminfo myserver | grep 'Rule'
Connect to
Guest Server
via host loopback mapping and port-forwarding forGuest S
neil@neil-VirtualBox$ ssh -p 2222 test@10.0.2.2
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Alternative: change (Guest S) /etc/sshd_config to listen on a
non-system port (> 1024). Then reload ssh.
I think the default networking setup for VirtualBox guest is NAT
and is not really intended to achieve this type of networking communication; but based on old posts may be possible by forwarding a non-system port to a Guest port and using the default loopback IP address to reach the Guest. 10.0.2.2 is default loopback.
Setup Networking
However, the easiest is to ensure you choose the correct networking for each of the Guests. Shutdown you guest machines, then in VirtualBox edit the Networking mode appropriate for your needs (note grid).
Using Default NAT Network
Using NAT, VirtualBox uses a special IP 10.0.2.2 as a loopback (at least I think this is still true). Therefore ports forwarded from loopback are available to all guests. I think you should be able to take advantage of this. To communicate using a NAT network, will require one of the following:
Using VBoxManage, setup NAT Forwarding of a non-system port (1024–65535) to a lower system port (< 1024).
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Guest S
IP address of10.0.2.15
, per the question.
Configure port forwarding on the Virtualbox Host, run:
VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
All TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). The name guestssh is purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the network card, like in other parts of VBoxManage.
Check the added rule:
VBoxManage showvminfo myserver | grep 'Rule'
Connect to
Guest Server
via host loopback mapping and port-forwarding forGuest S
neil@neil-VirtualBox$ ssh -p 2222 test@10.0.2.2
- In this case forward something like port 2222, to port 22 (default for SSH). This also assumes we'll use
Alternative: change (Guest S) /etc/sshd_config to listen on a
non-system port (> 1024). Then reload ssh.
edited Jun 15 at 21:31
answered Jun 15 at 21:26
mike stewart
291213
291213
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
add a comment |
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
How do I love thee? Let me count the ways
– Neil E
Jun 16 at 4:24
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
This formatting is driving me nuts. My previous comment is taken straight out of the help on how to make a line break and it isn't working for me. I have 2 spaces after 'How do I love thee? ' but 'Let me count the ways' is not on a new line.
– Neil E
Jun 16 at 4:26
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
Thanks Mike. My SSH is working. I have one concern. At one point in the process I got this message : The authenticity of host '[10.0.2.2]:2222 ([10.0.2.2]:2222)' can't be established. ECDSA key fingerprint is SHA256:kG7aJHOmo+ej8JF8L7iQ924NngwZv84ndtvCsEdBP/M. Are you sure you want to continue connecting (yes/no)? I answered 'yes' and continued, but I suspect I should really have answered 'no', then tried to resolve the issue. I will post what I did in a further comment. It made this comment too long to post.
– Neil E
Jun 16 at 4:33
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
When in doubt... esp when it comes to connecting to other servers (ssh/http/https/etc) search for an answer. Finding info has never been easier. But you might consider reading: stackoverflow.com/a/3664010 .... that said... and generally speaking connecting to resources on your own local network is pretty darn safe.
– mike stewart
Jul 25 at 21:28
add a comment |
up vote
0
down vote
Simply remove all ECDSA fingerprint keys (probably SHA256) contained within known-hosts directory.
- Run
vi ~/.ssh/known_hosts
- Delete all keys associated with subject IP-address within the known_hosts file.
- Enter "Esc"-key then "Shift"-key + ":" + "x"
add a comment |
up vote
0
down vote
Simply remove all ECDSA fingerprint keys (probably SHA256) contained within known-hosts directory.
- Run
vi ~/.ssh/known_hosts
- Delete all keys associated with subject IP-address within the known_hosts file.
- Enter "Esc"-key then "Shift"-key + ":" + "x"
add a comment |
up vote
0
down vote
up vote
0
down vote
Simply remove all ECDSA fingerprint keys (probably SHA256) contained within known-hosts directory.
- Run
vi ~/.ssh/known_hosts
- Delete all keys associated with subject IP-address within the known_hosts file.
- Enter "Esc"-key then "Shift"-key + ":" + "x"
Simply remove all ECDSA fingerprint keys (probably SHA256) contained within known-hosts directory.
- Run
vi ~/.ssh/known_hosts
- Delete all keys associated with subject IP-address within the known_hosts file.
- Enter "Esc"-key then "Shift"-key + ":" + "x"
answered Dec 11 at 2:34
alexanderjsingleton
1013
1013
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1046736%2fcommon-issue-ssh-connect-to-host-10-0-2-15-port-22-connection-refused%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please run
sudo ufw status
, and edit your question to add the output from that command.– vidarlo
Jun 15 at 4:50
make sure
PubkeyAuthentication
is set toyes
in/etc/ssh/sshd_config
– RoVo
Jun 15 at 9:12
Are the VM's networks configured as "NAT" or "NAT Network"?
– steeldriver
Jun 15 at 14:53
Um,
#PubkeyAuthentication yes
is commented out, you need to remove the hash. I'd have tested with a simple password first. Presumably the ssh traffic passes through the host and could be blocked by its firewall?– pbhj
Jun 15 at 21:59
Thanks for the responses. No success yet.
– Neil E
Jun 15 at 23:33