Program Club

호스트 localhost 포트 22에 연결 : 연결이 거부되었습니다.

proclub 2020. 10. 17. 12:32
반응형

호스트 localhost 포트 22에 연결 : 연결이 거부되었습니다.


내 로컬 컴퓨터에 hadoop을 설치하는 동안 다음 오류가 발생했습니다.

ssh -vvv localhost 
OpenSSH_5.5p1, OpenSSL 1.0.0e-fips 6 Sep 2011 
debug1: Reading configuration data /etc/ssh/ssh_config    
debug1: Applying options for * 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to localhost [127.0.0.1] port 22. 
debug1: connect to address 127.0.0.1 port 22: Connection refused 
ssh: connect to host localhost port 22: Connection refused

포트 번호를 변경하는 것 보다이 오류를 해결하는 데 도움이 될 수 있습니까?


맥 OSX에 하둡을 설치하는 경우에 반드시 차례 있도록 원격 로그인 에서 시스템 환경 설정은 다음 파일 공유 . 이것은 내 컴퓨터에서 작동했습니다.

원격 로그인


  1. 다음 명령을 사용하여 SSH를 제거합니다.

    sudo apt-get remove openssh-client openssh-server
    
  2. 다음을 사용하여 SSH를 다시 ​​설치하십시오.

    sudo apt-get install openssh-client openssh-server
    

그것은 당신의 문제를 해결할 것입니다.


당신은 한하십니까 sshd설치되어 있습니까? 다음을 통해 확인할 수 있습니다.

which ssh
which sshd

자세한 정보를 보려면 이 링크를 방문 하십시오 .


전체 SSH 패키지 팩을 설치해보십시오.

sudo apt-get install ssh

나는했다 ssh나의 우분투에 명령을하지만이 같은 오류가 발생했습니다. 전체 설치 후 모든 것이 해결되었습니다.


이 포트가 열려 있는지 확인하십시오. SSH 악마가 실행되고 있지 않을 수 있습니다. sshd가 실행 중인지 확인하십시오. 그렇지 않은 경우 시작하십시오.


/etc/hosts.allow에 다음이 포함되어 있는지 확인하십시오.

ssh:ALL:allow
sshd:ALL:allow

또는

ssh:localhost:allow
sshd:localhost:allow

또는-다른 변형

ssh:{host1,host2,host3...}:allow
sshd{host1,host2,host3...}:allow

파일의 첫 번째 줄이 ALL : ALL : DENY로 시작하지 않는지 확인하십시오.

어떤 포트에서도 호스트와 통신 할 수있는 것은 없습니다.


위의 모든 제안을 수행했지만 작동하지 않았습니다. 그런 다음 ssh 서비스를 다시 시작하면 작동합니다. 이것이 제가하는 것입니다:

service ssh restart

그런 다음 다시

ssh localhost

이제 로컬 호스트에 연결할 수 있습니다. 도움이되기를 바랍니다.


서비스를 다시 시작하면 작동합니다.

$ service sshd restart

그런 다음 확인

$ ssh localhost

작동합니다


내 경우 (ubuntu 14.04, 새로 설치) 다음 명령을 실행하면 작동합니다!

sudo apt-get install ssh


그 가치를 위해 vm에서 Ubuntu 16.04 Xenial을 실행하는 로컬 컴퓨터로 ssh를 시도하는 중 다음 오류가 발생했습니다.

 ssh: connect to host 192.168.144.18 port 22: Connection refused

다음과 같이 즉시 수정되었습니다.

sudo apt-get install ssh

Take note, Before fix: 'which sshd' returned nothing and 'which ssh' returned

/usr/bin/ssh

And After the fix: 'which sshd' returned

/usr/sbin/sshd

On mac go to system settings->network->sharing and allow remote login.

try ssh localhost

You should be good.


I used:

sudo service ssh start

Then:

ssh localhost

My port number is different. i tried using

ssh localhost -p 8088

this worked for me


If you still face problems, try the following:

sudo ufw enable    
sudo apt-get install openssh-server

This might work too.


It might be caused by some of the following:

  1. SSH Server is not installed (only SSH Client), try: apt-get install ssh openssh-client openssh-server
  2. Connection is blocked by iptables (Firewall), try: ufw allow ssh

Actually i solved this, I just installed shh daemon.

in terminal :

sudo apt-get install openssh-server


A way to do is to go to terminal

$ sudo gedit /etc/hosts

***enter your ip address ipaddress of your pc  localhost 
    ipaddress of your pc  localhost(Edit your pc name with localhost) **

and again restart your ssh service using:

$ service ssh restart

Problem will be resolve. Thanks


if you are using centOS or Red Hat, you should first update SElinux. Execute the following statement

ausearch -c 'sshd' --raw | audit2allow -M my-sshd

then you need to execute

semodule -i my-sshd.pp

good luck


If you're certain that you have installed ssh, then it's possible that ssh and/or sshd has been terminated or the server service hasn't been started. To check whether these processes are running use:

//this tells you whether your ssh instance is active/inactive
sudo service ssh status

OR

//this list all running processes whose names contain the string "ssh"
sudo ps -A | grep ssh

It's likely that ssh would be active and running but sshd would not. To enable them:

sudo service ssh start

NB; - some systems have a restart option but mine didn't


For Linux:

  1. Remove SSH with the following command:

    sudo apt-get remove openssh-client openssh-server
    
  2. Install SSH again with:

    sudo apt-get install openssh-client openssh-server
    

You may should edit your /etc/hosts. For example if my hostname is ub0, but the hostname in /etc/hosts is localhost, it may occur

connect to host ub0 port 22: Connection refused

Because the hostname in /etc/hosts is localhost not ub0.

So, you should be careful the hostname when building up distributed clusters.


you need to check the configuration in sshd_config ListenAddress 0.0.0.0 update this and restart the sshd service that will resolve the issue.


What worked for me is:

sudo mkdir /var/run/sshd
sudo apt-get install --reinstall openssh-server

I tried all the above mentioned solutions but somehow this directory /var/run/sshd was still missing for me. I have Ubuntu 16.04.4 LTS. Hope my answer helps if someone has the same issue.


if you are able to ping and not able to ssh, then it is a firewall. The firewall on 18.4 (not sure about other versions) in on by default and only allow port 8080.

Here how you fix it

https://linuxconfig.org/how-to-enable-disable-firewall-on-ubuntu-18-04-bionic-beaver-linux

참고URL : https://stackoverflow.com/questions/17335728/connect-to-host-localhost-port-22-connection-refused

반응형