ssh: connect to host ipaddress port 22: Operation not permitted

6,423

I don't know if it's foolish or what, but maybe this experience help someone else later.

The problem was solved when I disabled my firewall in remote system (Cuz i'm trying ssh via git bash in windows). And I can connect by root and newuser now.

Share:
6,423

Related videos on Youtube

Alex Jolig
Author by

Alex Jolig

Updated on September 18, 2022

Comments

  • Alex Jolig
    Alex Jolig over 1 year

    I've installed CentOs 7 on my server and trying to connect to it by ssh ipaddress but I get following error: ssh: connect to host 172.20.2.74 port 22: Operation not permitted

    In order to solve this error I have done these solution:

    1. In /etc/ssh/sshd_config I have set PermitRootLogin to yes
    2. I've created new user and tried to ssh by ssh newuser@ipaddress

    But No matter what I do, I always get the same error and couldn't find anything helpful in net.

    Is there somthing that I'm missing there, maybe somthing in sshd_config?

    Update Due to @Rabban comment.. I added -vvv to ssh command and here's the result:

    $ ssh -vvv ipaddress
    OpenSSH_7.3p1, OpenSSL 1.0.2k  26 Jan 2017
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug2: resolving "ipaddress" port 22
    debug2: ssh_connect_direct: needpriv 0
    debug1: Connecting to ipaddress [ipaddress] port 22.
    debug1: connect to address ipaddress port 22: Operation not permitted
    ssh: connect to host ipaddress port 22: Operation not permitted
    
    • Yaron
      Yaron almost 7 years
      Are you sure that sshd is running on the machine? what is the result of running ssh localhost from the machine to itself?
    • Satō Katsura
      Satō Katsura almost 7 years
    • Alex Jolig
      Alex Jolig almost 7 years
      @SatoKatsura I've checked that question. nothing there was helpful
    • Alex Jolig
      Alex Jolig almost 7 years
      @Yaron I've ran ssh by service sshd start
    • user6075516
      user6075516 almost 7 years
      Try sshing with the -vvv flag and append the output to your question. The relevant section of journalctl -u sshd couldn't hurt either.
    • Alex Jolig
      Alex Jolig almost 7 years
      @Rabban The first part is done. As for the second part of your comment I have no idea what did you mean!