linux - ssh: connection refused on port 22 -
i have installed openssh-sever
. started ssh-server
using following command :
:~$ sudo service ssh start ssh start/running, process 20013
with following command can see port 22 open :
:~$ sudo nmap localhost -p 1-65535 starting nmap 6.40 ( http://nmap.org ) @ 2015-04-22 23:46 edt nmap scan report localhost (127.0.0.1) host (0.000013s latency). not shown: 65533 closed ports port state service 22/tcp open ssh 631/tcp open ipp nmap done: 1 ip address (1 host up) scanned in 7.24 seconds
furthermore, check if port listening used following command results :
:~$ sudo netstat -plunt active internet connections (only servers) proto recv-q send-q local address foreign address state pid/program name tcp 0 0 127.0.1.1:53 0.0.0.0:* listen 1061/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* listen 20013/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* listen 2009/cupsd tcp6 0 0 :::22 :::* listen 20013/sshd tcp6 0 0 ::1:631 :::* listen 2009/cupsd udp 0 0 0.0.0.0:42198 0.0.0.0:*
but when try connect port same machine following message :
:~$ ssh -vvv -p 22 address 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 * debug2: ssh_connect: needpriv 0 debug1: connecting address [198.105.xxx.xxx] port 22. debug1: connect address 198.105.xxx.xxx port 22: connection timed out
when try ssh
different computer on different network following message(xx.xxx.xxx.xxx external/public ip of router) :
:~ssh bhuwan@xx.xxx.xxx.xxx ssh: connect host xx.xxx.xxx.xxx port 22: connection refused
whereas, when try ssh
different computer on same network able connect. have port forwarding enabled on router on port 22 local ip of computer. literally started using ubuntu
2 days ago , started working on ssh
same day. i'm not expert on of , simplified explanation or guidance appreciated. :)
below sshd_config
file:
# package generated configuration file # see sshd_config(5) manpage details # ports, ips , protocols listen port 22 # use these options restrict interfaces/protocols sshd bind #listenaddress :: #listenaddress 0.0.0.0 protocol 2 # hostkeys protocol version 2 hostkey /etc/ssh/ssh_host_rsa_key hostkey /etc/ssh/ssh_host_dsa_key hostkey /etc/ssh/ssh_host_ecdsa_key hostkey /etc/ssh/ssh_host_ed25519_key #privilege separation turned on security useprivilegeseparation yes # lifetime , size of ephemeral version 1 server key keyregenerationinterval 3600 serverkeybits 1024 # logging syslogfacility auth loglevel info # authentication: logingracetime 120 permitrootlogin without-password strictmodes yes rsaauthentication yes pubkeyauthentication yes #authorizedkeysfile %h/.ssh/authorized_keys # don't read user's ~/.rhosts , ~/.shosts files ignorerhosts yes # work need host keys in /etc/ssh_known_hosts rhostsrsaauthentication no # similar protocol version 2 hostbasedauthentication no # uncomment if don't trust ~/.ssh/known_hosts rhostsrsaauthentication #ignoreuserknownhosts yes # enable empty passwords, change yes (not recommended) permitemptypasswords no # change yes enable challenge-response passwords (beware issues # pam modules , threads) challengeresponseauthentication no # change no disable tunnelled clear text passwords #passwordauthentication yes # kerberos options #kerberosauthentication no #kerberosgetafstoken no #kerberosorlocalpasswd yes #kerberosticketcleanup yes # gssapi options gssapiauthentication yes #gssapicleanupcredentials yes allowtcpforwarding yes x11forwarding yes x11displayoffset 10 printmotd no printlastlog yes tcpkeepalive yes #uselogin no #maxstartups 10:30:60 #banner /etc/issue.net # allow client pass locale environment variables acceptenv lang lc_* subsystem sftp /usr/lib/openssh/sftp-server # set 'yes' enable pam authentication, account processing, # , session processing. if enabled, pam authentication # allowed through challengeresponseauthentication , # passwordauthentication. depending on pam configuration, # pam authentication via challengeresponseauthentication may bypass # setting of "permitrootlogin without-password". # if want pam account , session checks run without # pam authentication, enable set passwordauthentication # , challengeresponseauthentication 'no'. usepam yes
and ssh_config
file follows:
# ssh client system-wide configuration file. see # ssh_config(5) more information. file provides defaults # users, , values can changed in per-user configuration files # or on command line. # configuration data parsed follows: # 1. command line options # 2. user-specific file # 3. system-wide file # configuration value changed first time set. # thus, host-specific definitions should @ beginning of # configuration file, , defaults @ end. # site-wide defaults commonly used options. comprehensive # list of available options, meanings , defaults, please see # ssh_config(5) man page. host * serveraliveinterval 300 # forwardagent no # forwardx11 no # forwardx11trusted yes # rhostsrsaauthentication no # rsaauthentication yes # passwordauthentication yes # hostbasedauthentication no # gssapiauthentication no # gssapidelegatecredentials no # gssapikeyexchange no # gssapitrustdns no # batchmode no # checkhostip yes # addressfamily # connecttimeout 0 # stricthostkeychecking ask # identityfile ~/.ssh/identity # identityfile ~/.ssh/id_rsa # identityfile ~/.ssh/id_dsa # port 22 # protocol 2,1 # cipher 3des # ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc # macs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160 # escapechar ~ # tunnel no # tunneldevice any:any # permitlocalcommand no # visualhostkey no # proxycommand ssh -q -w %h:%p gateway.example.com # rekeylimit 1g 1h sendenv lang lc_* hashknownhosts yes gssapiauthentication yes gssapidelegatecredentials no
after long haul found out problem modem isp provided. above configuration should work fine if modem/router has port forwarding not blocked isp. modem/router isp provided, after tried port forwarding, port 22 not open can checked here: http://www.canyouseeme.org/
.