Try DigitalOcean free for up to two months!

sshpass & ssh does not cooperate?

Discussion in 'Command Line' started by postcd, Mar 14, 2017.

  1. postcd

    postcd Member

    Joined:
    Apr 16, 2014
    Messages:
    146
    Likes Received:
    10
    Hello,

    around 3 years back i used sshpass to input password to the ssh command and i believe it worked.
    But now it does not work.

    manual: https://linux.die.net/man/1/sshpass

    So i run the command:
    and i do not see it setup a SSH connection. When i use bad password, it reports denied access.

    command ssh h -f -N -D 0.0.0.0:1080 localhost is working very well without any problem but i wanted to show you something i noticed when i run with verbose enabled :

    And SSHPASS:

    I noticed that with sshpass the last line "Entering interactive session." is not present in debug log.

    When i disabled GSSAPIAuthentication, i do not see any errors:

    tail /var/log/secure shows:
    Is there any workaround so i can run that ssh command from within bash script without need to input password myself? (i know it is security issue)

    Thank You
     
    Last edited: Mar 14, 2017
  2. JasKinasis

    JasKinasis Active Member

    Joined:
    Jun 17, 2014
    Messages:
    223
    Likes Received:
    127
    Now, I'm no sys-admin - but I'd say your best bet would be to set up some ssh keys.
    I used to have a couple of servers on my home network a few years ago. I used to access them over ssh using encrypted public keys, rather than using a password.

    Once the keys are set-up and working with ssh, you can disable ssh password logins on the remote server/s.
     
  3. rstanley

    rstanley Active Member

    Joined:
    Aug 22, 2013
    Messages:
    311
    Likes Received:
    218
    Set up public/private keys using ssh-keygen, then upload ONLY the PUBLIC key to the server using ssh-copy-id, and then you only need to type "ssh example", if you setup the site as "Host example" in your ~/.ssh/config file.

    Also, PLEASE, PLEASE set PermitRootLogin, on the servers, to "no" to force the user to login as a regular user. Also PLEASE, PLEASE change the default ssh port (22) on all the servers you have the authority to do, (Or take the Sys Admin for the server in question, out for a couple of good beers!) to a different (Much higher) port number! I speak from experience of hundreds if not thousands attempted logins per day on an open port 22! Of course, I also ass/u/me that your user password is NOT "password"! ;^)
     
    postcd likes this.
  4. postcd

    postcd Member

    Joined:
    Apr 16, 2014
    Messages:
    146
    Likes Received:
    10
    Thx for advice regarding SSH keys. So i was googling and here are commands that i tried:

    (enter to every prompt)
    then:
    I did it wrong? If so, how better i can do it please? Thx
     
  5. jakester

    jakester New Member

    Joined:
    Saturday
    Messages:
    3
    Likes Received:
    0
    havent you been working with ssh for years now? and it took you longer to post your 'question' than it would have taken you to just try it and find out if it worked.

    and are you seriously logging in as ROOT over a network? thats incredibly dangerous, stupid, and lazy. if you keyswap your normal account, you can omit all the flags and just type "ssh user@host", and get in. need root from there, type in su or use sudo for what it was written for.
     
  6. postcd

    postcd Member

    Joined:
    Apr 16, 2014
    Messages:
    146
    Likes Received:
    10
    i do not need to login, i need to setup reverse proxy if i understand good. if anyone knows right way or can narrow my above mentioned command, please kindly contribute. Thank You
     
  7. jakester

    jakester New Member

    Joined:
    Saturday
    Messages:
    3
    Likes Received:
    0
    you dont understand and if you arent clear after 3 years you should hire someone that knows what theyre doing. you could put 'ssh reverse proxy' into google if thats not too hard for you and read the first result that tells you how to do it. or you could use ssh-keys as everyone has told you and followed the howtos for that too. all that dosnt matter, since your an absolute moron if you log in as root over a network for any reasons.
     
  8. postcd

    postcd Member

    Joined:
    Apr 16, 2014
    Messages:
    146
    Likes Received:
    10
    Solution not found yet, i read some articles about this, but do not understand. If anyone can narrow my command it would be helpful.
     

Share This Page