ssh: connect to host 127.0.0.1 port 2222: Connection refused

https://askubuntu.com/questions/673597/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


Note, that 127.0.0.1 aka localhost is your local machine. Usually at this point you use the IP address or 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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值