Hello I've created a user in Ubuntu and I want to connect to it using ssh using this command

ssh user@ -p 2222

and I got this error

ssh: connect to host port 2222: Connection refused

I tried

ssh -vvv user@ -p 2222

and got

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to [] port 2222.
debug1: connect to address port 2222: Connection refused
sssh: connect to host port 2222: Connection refused

any help ?

Note : I am using virtualbox

Tell me the best way to install and configure ssh?

Best Answer

Note, that aka localhost is your local machine. Usually at this point you use the ip address or the hostname of the remote host

  • First install the ssh server and client on your target host and your local host

    sudo apt-get install ssh

    A configuration isn't necessary.

  • Per default SSH is listening on port 22, therefore use

    ssh user@ -p 22


    ssh user@
  • Or reconfigure the port for the ssh server (target host)

    sudo nano /etc/ssh/sshd_config

    and change

    Port 22


    Port 2222

    reload the configuration

    sudo service ssh force-reload

    and connect via

    ssh user@ -p 2222