How can I 'ssh' to an ubuntu server running on VirutalBox












1















I have installed Ubuntu Server on a virtual machine in VirtualBox which runs on Windows 7.
How can I connect through ssh to that virtual machine?



I go and type 'ifconfig', and i get this address "10.0.2.15". But when I try ssh 10.0.2.15 it can't establish the connection.










share|improve this question





























    1















    I have installed Ubuntu Server on a virtual machine in VirtualBox which runs on Windows 7.
    How can I connect through ssh to that virtual machine?



    I go and type 'ifconfig', and i get this address "10.0.2.15". But when I try ssh 10.0.2.15 it can't establish the connection.










    share|improve this question



























      1












      1








      1








      I have installed Ubuntu Server on a virtual machine in VirtualBox which runs on Windows 7.
      How can I connect through ssh to that virtual machine?



      I go and type 'ifconfig', and i get this address "10.0.2.15". But when I try ssh 10.0.2.15 it can't establish the connection.










      share|improve this question
















      I have installed Ubuntu Server on a virtual machine in VirtualBox which runs on Windows 7.
      How can I connect through ssh to that virtual machine?



      I go and type 'ifconfig', and i get this address "10.0.2.15". But when I try ssh 10.0.2.15 it can't establish the connection.







      12.04 virtualbox ssh nat






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 30 '12 at 16:55









      Salem

      17.2k65083




      17.2k65083










      asked Nov 8 '12 at 22:55









      michaelmichael

      2,00482126




      2,00482126






















          2 Answers
          2






          active

          oldest

          votes


















          2














          The easiest way is to set up the network interface of the virtual machine to "Bridged mode" in virtualbox.



          You do that by selecting the virtual machine (in VB) then go to settings > network, and change the attached to dropdown from NAT to bridged



          After that, you virtual machine should get an IP address of your local network (similar tot he one of the host pc) and you should be able to ssh it with that IP.






          share|improve this answer


























          • Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

            – tomodachi
            Nov 8 '12 at 23:59













          • thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

            – Sam
            Nov 9 '12 at 1:01



















          1














          You can achieve this by forwarding ports to the virtual machine.

          Make sure your virtual machine has openssh-server installed and running!




          Open VirtualBox -> Click on your VM -> "Settings" -> "Network" -> "Advanced" -> "Port Forwarding"




          Click the icon in the top right which has a plus (+) symbol to add a port forwarding rule and enter the following data:



          Name: ssh (or whatever you want)
          Protocol: TCP
          Host IP: 127.0.0.1
          Host port: 2222
          Guest port: 22


          Note that the host port is not the usual ssh port of 22.

          Now you can ssh into your virtual machine!



          ssh user@localhost -p 2222





          share|improve this answer










          New contributor




          conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            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',
            autoActivateHeartbeat: false,
            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
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f214774%2fhow-can-i-ssh-to-an-ubuntu-server-running-on-virutalbox%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









            2














            The easiest way is to set up the network interface of the virtual machine to "Bridged mode" in virtualbox.



            You do that by selecting the virtual machine (in VB) then go to settings > network, and change the attached to dropdown from NAT to bridged



            After that, you virtual machine should get an IP address of your local network (similar tot he one of the host pc) and you should be able to ssh it with that IP.






            share|improve this answer


























            • Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

              – tomodachi
              Nov 8 '12 at 23:59













            • thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

              – Sam
              Nov 9 '12 at 1:01
















            2














            The easiest way is to set up the network interface of the virtual machine to "Bridged mode" in virtualbox.



            You do that by selecting the virtual machine (in VB) then go to settings > network, and change the attached to dropdown from NAT to bridged



            After that, you virtual machine should get an IP address of your local network (similar tot he one of the host pc) and you should be able to ssh it with that IP.






            share|improve this answer


























            • Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

              – tomodachi
              Nov 8 '12 at 23:59













            • thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

              – Sam
              Nov 9 '12 at 1:01














            2












            2








            2







            The easiest way is to set up the network interface of the virtual machine to "Bridged mode" in virtualbox.



            You do that by selecting the virtual machine (in VB) then go to settings > network, and change the attached to dropdown from NAT to bridged



            After that, you virtual machine should get an IP address of your local network (similar tot he one of the host pc) and you should be able to ssh it with that IP.






            share|improve this answer















            The easiest way is to set up the network interface of the virtual machine to "Bridged mode" in virtualbox.



            You do that by selecting the virtual machine (in VB) then go to settings > network, and change the attached to dropdown from NAT to bridged



            After that, you virtual machine should get an IP address of your local network (similar tot he one of the host pc) and you should be able to ssh it with that IP.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 '12 at 1:00

























            answered Nov 8 '12 at 23:14









            SamSam

            2,003910




            2,003910













            • Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

              – tomodachi
              Nov 8 '12 at 23:59













            • thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

              – Sam
              Nov 9 '12 at 1:01



















            • Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

              – tomodachi
              Nov 8 '12 at 23:59













            • thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

              – Sam
              Nov 9 '12 at 1:01

















            Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

            – tomodachi
            Nov 8 '12 at 23:59







            Actually you don't need to set it up in bridged mode, but bridged mode is the easiest way to solve your issue. If you want to keep your machine in NAT, you have to do a port forward rule in your virtualbox machine NAT settings.

            – tomodachi
            Nov 8 '12 at 23:59















            thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

            – Sam
            Nov 9 '12 at 1:01





            thanks tomodachi, i updated the answer to reflect it's the easiest and not the only way

            – Sam
            Nov 9 '12 at 1:01













            1














            You can achieve this by forwarding ports to the virtual machine.

            Make sure your virtual machine has openssh-server installed and running!




            Open VirtualBox -> Click on your VM -> "Settings" -> "Network" -> "Advanced" -> "Port Forwarding"




            Click the icon in the top right which has a plus (+) symbol to add a port forwarding rule and enter the following data:



            Name: ssh (or whatever you want)
            Protocol: TCP
            Host IP: 127.0.0.1
            Host port: 2222
            Guest port: 22


            Note that the host port is not the usual ssh port of 22.

            Now you can ssh into your virtual machine!



            ssh user@localhost -p 2222





            share|improve this answer










            New contributor




            conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

























              1














              You can achieve this by forwarding ports to the virtual machine.

              Make sure your virtual machine has openssh-server installed and running!




              Open VirtualBox -> Click on your VM -> "Settings" -> "Network" -> "Advanced" -> "Port Forwarding"




              Click the icon in the top right which has a plus (+) symbol to add a port forwarding rule and enter the following data:



              Name: ssh (or whatever you want)
              Protocol: TCP
              Host IP: 127.0.0.1
              Host port: 2222
              Guest port: 22


              Note that the host port is not the usual ssh port of 22.

              Now you can ssh into your virtual machine!



              ssh user@localhost -p 2222





              share|improve this answer










              New contributor




              conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                1












                1








                1







                You can achieve this by forwarding ports to the virtual machine.

                Make sure your virtual machine has openssh-server installed and running!




                Open VirtualBox -> Click on your VM -> "Settings" -> "Network" -> "Advanced" -> "Port Forwarding"




                Click the icon in the top right which has a plus (+) symbol to add a port forwarding rule and enter the following data:



                Name: ssh (or whatever you want)
                Protocol: TCP
                Host IP: 127.0.0.1
                Host port: 2222
                Guest port: 22


                Note that the host port is not the usual ssh port of 22.

                Now you can ssh into your virtual machine!



                ssh user@localhost -p 2222





                share|improve this answer










                New contributor




                conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                You can achieve this by forwarding ports to the virtual machine.

                Make sure your virtual machine has openssh-server installed and running!




                Open VirtualBox -> Click on your VM -> "Settings" -> "Network" -> "Advanced" -> "Port Forwarding"




                Click the icon in the top right which has a plus (+) symbol to add a port forwarding rule and enter the following data:



                Name: ssh (or whatever you want)
                Protocol: TCP
                Host IP: 127.0.0.1
                Host port: 2222
                Guest port: 22


                Note that the host port is not the usual ssh port of 22.

                Now you can ssh into your virtual machine!



                ssh user@localhost -p 2222






                share|improve this answer










                New contributor




                conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer








                edited 1 hour ago





















                New contributor




                conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 2 hours ago









                conkueconkue

                114




                114




                New contributor




                conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                conkue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f214774%2fhow-can-i-ssh-to-an-ubuntu-server-running-on-virutalbox%23new-answer', 'question_page');
                    }
                    );

                    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







                    Popular posts from this blog

                    香粉寮

                    GameSpot