2

I am here because I've found different problems setting up SSH using this guide proposed in this other question.

First of all I've a computer (I want to use it as master) called: timmy@timmy-Lenovo-G50-80. My other computer is a Virtual Machine always with linux mint called: test@test-VirtualBox and I'd like to use it as a slave.

What I've done until now is:

  1. install needed packets (both PC):

    sudo apt-get install openssh-server openssh-client
    
  2. Change inside the file /etc/ssh/sshd_config: (Only master)

    • the port of server from 22 to 2222
    • set PubkeyAuthentication yes (so no change)
    • remove comment at line: Banner /etc/issue.net
  3. STOP

I am stuck when I've to execute this command:

ssh-copy-id username@remotehost

I imagine, reading what's written, that I've to execute something like:

ssh-copy-id timmy@timmy-Lenovo-G50-80

but:

  • from timmy@timmy-Lenovo-G50-80 everything goes OK, I can connect to myself (not what I actually want)
  • from test@test-VirtualBox it tells me ERROR: ssh: Could not resolve hostname timmy@timmy-Lenovo-G50-80: Name or service not known

Finally, what I've to do in order to connect these 2 PC?

Community
  • 1
  • 1
Timmy
  • 693
  • 2
  • 8
  • 26

1 Answers1

1

You need to enable port forwarding into your VirtualBox'ed machine. Simply right click on the virtual machine, then go into Network. Then click on advance which will expand the Network window, and then on the button that appeared labeled Port forwarding.

A table will appear with several columns (Name, Protocol, Host IP, Host Port, ...). Simply add a new entry for protocol TCP, host port = X and guest port = 22 (see the list of well-known ports here https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports). The screenshot below is from my cloudera quickstart VM. Notice the outlined entry in the port forwarding rules, which is about setting up the SSH port in the guest OS.

enter image description here

Once you reboot the virtual machine, you can simply connect to it through

# ssh -p X localhost

the -p parameter tells to connect through the port X. Notice that if you want to use scp then you have to use the uppercase -P option rather than the lowercase -p.

# scp -P X localfile localhost:remote-dir/
Harald
  • 3,110
  • 1
  • 24
  • 35
  • Ok inserted Rule1 as in your image: host port: 2222 - guest port: 22. Rebooted VM and in terminal I've written: `ssh -p 2222 timmy@timmy-Lenovo-G50-80` but nothing, same as before. Moreover I tried also `ssh-copy-id timmy@timmy-Lenovo-G50-80`, still couldn't find anything. – Timmy Apr 08 '16 at 14:39
  • If you want to use names for the machines other than localhost you should add entries to /etc/hosts in both systems as described in http://www.tldp.org/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap9sec95.html . Both systes shoud point to 127.0.0.1. – Harald Apr 08 '16 at 16:21
  • Ok, I understand what you're telling to me. So my master address is: `192.168.1.18`. I tried to export the key from my slave writing `ssh-copy-id 192.168.1.18` but it now ask me a password. It isn't neither my master psw nor my slave psw. I tried also nothing, `root` and `toor` but no way. What I have to write? – Timmy Apr 08 '16 at 16:43
  • uhm, that i can't say. However, 127.0.0.1 always point to the own system, can you try with this instead? – Harald Apr 08 '16 at 16:47
  • with 127.0.0.1 goes, now I've installed the key. (This time also asked me the password and was the one of the machine). And now? How can I connect the 2 machines? – Timmy Apr 08 '16 at 17:03
  • Ok to connect from the slave to the master, I've to write: `ssh timmy@192.168.1.18`. But now I've another problem: how can I do the opposite thing? Connect master to slave? I don't know how to find his IP – Timmy Apr 08 '16 at 17:27
  • OK Solved! Now I can connect to both PC using SSH. The solution was to change the network connection from NAT to Bridged networking – Timmy Apr 08 '16 at 17:42