Search code examples
ubuntusshscp

Difference between ssh and scp command


I am playing with overthewire's bandit wargame. In Level 18, the bashrc file is configured in such a way that, it will immediately log out users who try to log in, after verifying password of-course. For example:

ssh bandit18@bandit.labs.overthewire.org -p 2220

does not work. Users will be immediately logout. So, I tried with scp, the password is incorrect.

scp bandit18@bandit.labs.overthewire.org:2220/home/bandit18/readme .

Even though I manage to successfully log in using the password I have. Finally the following command works, I don't know about this either.

ssh bandit18@bandit.labs.overthewire.org -p 2220 "cat ~/readme"

How come, "cat ˜/readme" does the trick, read the file without login or whats procedure here?

So my questions are: 1) How come the same password is valid for ssh but not for scp? 2) How come ssh does not work, but ssh with the cat command specified works?

Thanks.

PS: If any wants here's the password: kfBf3eYk5BPBRzwjqutbbfE887SVc5Yd


Solution

    1. scp is working: scp -P 2220 bandit18@bandit.labs.overthewire.org:/home/bandit18/readme .

    2. .bashrc contains exit 0 so bash exited immediately after you login via ssh:

      > ssh bandit18@bandit.labs.overthewire.org -p 2220 "tail -n 2 .bashrc"
      This is a OverTheWire game server. More information on http://www.overthewire.org/wargames
      
      bandit18@bandit.labs.overthewire.org's password: 
      echo 'Byebye !'
      exit 0