Support Questions

Find answers, ask questions, and share your expertise

Issue using scp on HDP 2.4: "ssh: connect to host localhost port 2222: Connection refused"

I am trying to setup nifi on HDP 2.4 (Oracle Virtual Box on Windows 10) for the sentiment analysis tutorial, but when I try to transfer the HortonWorks DataFlow file to the virtual machine with the command:

scp -P 2222 ~/Downloads/HDF-1.2.0.1-1.tar.gz root@localhost:/root

I get the error:

ssh: connect to host localhost port 2222: Connection refused
lost connection

I added port forwarding for ssh in Virtual Box with Protocol=TCP, Host IP = 127.0.0.1, Host Port = 2222, and Guest Port=22. Also, I was able to successfully log in to Ambari and everything seems to be working. Furthermore, I added Virtual Box to my Firewall exceptions in case it was being blocked and am using the NAT network mode. I'm at a loss at this point. Any ideas as to why I can't connect using ssh?

18 REPLIES 18

@Sergei

Run ifconfig on your vm and paste the output here.

Also check if any firewall is running on your vm.

Firewall Status:

[root@sandbox ~]# ../etc/init.d/iptables status                                                                                                               
iptables: Firewall is not running.     

ifconfig:

[root@sandbox ~]# ifconfig                                                                                                                                    
eth0      Link encap:Ethernet  HWaddr 08:00:27:38:3F:58                                                                                                       
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0                                                                                           
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                                                                                                  
          RX packets:405 errors:0 dropped:0 overruns:0 frame:0                                                                                                
          TX packets:317 errors:0 dropped:0 overruns:0 carrier:0                                                                                              
          collisions:0 txqueuelen:1000                                                                                                                        
          RX bytes:125804 (122.8 KiB)  TX bytes:108667 (106.1 KiB)                                                                                            
          Interrupt:19 Base address:0xd020                                                                                                                    
                                                                                                                                                              
lo        Link encap:Local Loopback                                                                                                                           
          inet addr:127.0.0.1  Mask:255.0.0.0                                                                                                                 
          UP LOOPBACK RUNNING  MTU:65536  Metric:1                                                                                                            
          RX packets:10898 errors:0 dropped:0 overruns:0 frame:0                                                                                              
          TX packets:10898 errors:0 dropped:0 overruns:0 carrier:0                                                                                            
          collisions:0 txqueuelen:0                                                                                                                           
          RX bytes:7618934 (7.2 MiB)  TX bytes:7618934 (7.2 MiB) 

Super Collaborator

can you show the content of /etc/hosts file using:

cat /etc/hosts

[root@sandbox ~]# cat /etc/hosts
# File is generated from /usr/lib/hue/tools/start_scripts/gen_hosts.sh  
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
10.0.2.15       sandbox.hortonworks.com sandbox ambari.hortonworks.com

[root@sandbox ~]# cat /etc/hosts                                                                                               
# File is generated from /usr/lib/hue/tools/start_scripts/gen_hosts.sh                                                         
# Do not remove the following line, or various programs                                                                        
# that require network functionality will fail.                                                                                
127.0.0.1               localhost.localdomain localhost                                                                        
10.0.2.15       sandbox.hortonworks.com sandbox ambari.hortonworks.com  

Super Collaborator

can you try doing SSH in with the -v option to give the verbose output

ssh root@localhost -v

[root@sandbox ~]# ssh root@localhost -v
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: Applying options for * 
debug1: Connecting to localhost [127.0.0.1] port 22. 
debug1: Connection established. 
debug1: permanently_set_uid: 0/0 
debug1: identity file /root/.ssh/identity type -1   
debug1: identity file /root/.ssh/identity-cert type -1   
debug1: identity file /root/.ssh/id_rsa type 1 
debug1: identity file /root/.ssh/id_rsa-cert type -1 
debug1: identity file /root/.ssh/id_dsa type -1  
debug1: identity file /root/.ssh/id_dsa-cert type -1  
debug1: identity file /root/.ssh/id_ecdsa type -1 
debug1: identity file /root/.ssh/id_ecdsa-cert type -1 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.3 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-ctr hmac-md5 none 
debug1: kex: client->server aes128-ctr hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Host 'localhost' is known and matches the RSA host key. 
debug1: Found key in /root/.ssh/known_hosts:1 
debug1: ssh_rsa_verify: signature correct 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password 
debug1: Next authentication method: gssapi-keyex  
debug1: No valid Key exchange context 
debug1: Next authentication method: gssapi-with-mic 
debug1: Unspecified GSS failure. Minor code may provide more information 

Credentials cache file '/tmp/krb5cc_0' not found 

debug1: Unspecified GSS failure. Minor code may provide more information 

Credentials cache file '/tmp/krb5cc_0' not found  

debug1: Unspecified GSS failure. Minor code may provide more information 
debug1: Unspecified GSS failure. Minor code may provide more information 

Credentials cache file '/tmp/krb5cc_0' not found 

debug1: Next authentication method: publickey 
debug1: Trying private key: /root/.ssh/identity 
debug1: Server accepts key: pkalg ssh-rsa blen 277 
debug1: read PEM private key done: type RSA  
debug1: Authentication succeeded (publickey). 
debug1: Requesting no-more-sessions@openssh.com 
debug1: Entering interactive session. 
debug1: Sending environment.
Last login: Tue May 31 14:56:34 2016 from 10.0.2.15

Sergei

Are you running any other VM other than this sandbox?

Can you try restarting you host (Windows 10)?

I have other VMs on my Virtual Box but they aren't running when I run HDP 2.4. I've tried restarting but it still doesn't work.

You are trying to do ssh on same server or from outside?

New Contributor

I am having the same issue..has there been any resolution?

New Contributor

can you try disabling your windows firewall?

Super Guru
@Sergei

Can you restart network service of your HDP VM?

service network restart

I have faced similar issue for Sandbox multiple times and I could resolve it by restarting network service.

New Contributor
@Sergei

Hi, was this issue ever resolved? If s could you please share resolution if you don't mind?

I'm having the exact same issue and not sure how to proceed at this point.

New Contributor

@Sergei What is the status of sshd service? Could you try restarting sshd service by command service sshd restart ?

Does anyone get to the solution of the issue till date? plz share..

New Contributor

Hey,

I think the solution should follow this action plan:

  1. install iptables e.g. this way https://stackoverflow.com/questions/24756240/how-can-i-use-iptables-on-centos-7
  2. then you need to open the 2222 port https://stackoverflow.com/questions/19034542/how-to-open-port-in-centos
  3. send the file over ( in my case )
 scp /home/pchpc/vms/file root@192.168.0.7:/root/

This has worked for me.

Hope this helps

Explorer

Try to connect to vm with vm ip.

ssh -P 2222 someFiles root@10.0.2.15:/root