ssh: connect to host 127.0.0.1 port 2222: Connection refused
Hello I've created a user in Ubuntu and I want to connect to it using ssh
using this command
ssh user@127.0.0.1 -p 2222
and I got this error
ssh: connect to host 127.0.0.1 port 2222: Connection refused
I tried
ssh -vvv user@127.0.0.1 -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 127.0.0.1 [127.0.0.1] port 2222.
debug1: connect to address 127.0.0.1 port 2222: Connection refused
sssh: connect to host 127.0.0.1 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 127.0.0.1 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@127.0.0.1 -p 22
or
ssh user@127.0.0.1
Or reconfigure the port for the ssh server (target host)
sudo nano /etc/ssh/sshd_config
and change
Port 22
to
Port 2222
reload the configuration
sudo service ssh force-reload
and connect via
ssh user@127.0.0.1 -p 2222