Here is the case

Im using port different port for ssh on all linux servers . And i generated ssh keys and when i use

ssh oracle@proddb -pxxxxx

server logins with no problem

But if i use "ssh proddb" connection is refused

ssh: connect to host proddb port 22: Connection refused 


ssh -v prodb

> OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 debug1: Reading
> configuration data /etc/ssh/ssh_config debug1: Applying options for *
> debug1: Connecting to proddb [xxx.xxx.xxx.xxx] port 22. debug1:
> connect to address xxx.xxx.xxx.xxx port 22: Connection refused ssh:
> connect to host proddb port 22: Connection refused
  • distant host is not listening on port 22, and by the way your public key are deployed on root account, you should user root@ too. – Archemar Aug 10 '17 at 9:14
  • sorry it is oracle user, on some servers "ssh proddb" command works and on some it is not – OmiPenguin Aug 10 '17 at 9:18
  • then your public keys are to be deployed on remote oracle account. (e.g. in ~oracle/.ssh/authorized_keys ) – Archemar Aug 10 '17 at 9:31

SSH is using port 22 as default port. You could create a config file in your .ssh folder and configure your port etc.:

content of $HOME/.ssh/config

Host proddb
    HostName proddb
    Port xxxx
    User root
  • There is already a file in "oracle's/.ssh/config" and it is using port 15666 which is correct i added "User oracle" and then restarted service. But still giving connection refused – OmiPenguin Aug 10 '17 at 9:17
  • 1
    check the syntax of your config file start ssh with "-v" to debug you should see line like this debug1: Reading configuration data /home/oracle/.ssh/config – Vafa Aug 10 '17 at 9:22
  • 1
    Your verbosity list shows, ssh is reading config from wrong file --- debug1: Reading configuration data /etc/ssh/ssh_config --- It must read it from your "/home/oracle/.ssh/config" – Vafa Aug 10 '17 at 10:06
  • This solution worked, further more i edited /etc/ssh/ssh_config and altered the port and it also worked. Thanks @vafa – OmiPenguin Aug 10 '17 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.