ssh和scp命令之间的区别



我正在玩overthewire的土匪战争游戏。在级别18中,bashrc文件的配置方式是,它将在验证密码后立即注销试图登录的用户。例如:

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

不起作用。用户将立即注销。所以,我尝试了scp,密码不正确。

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

尽管我设法使用我的密码成功登录。最后,以下命令有效,我也不知道这一点。

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

为什么,"cat ~/readme"会这么做,在没有登录的情况下读取文件,或者这里的过程是什么?

所以我的问题是:1( 为什么相同的密码对ssh有效而对scp无效?2( 为什么ssh不起作用,但指定了cat命令的ssh起作用?

谢谢。

PS:如果有人想要,这里有密码:kfBf3eYk5BPBRzwjqutbbfE887SVc5Yd

  1. scp正在工作:scp -P 2220 bandit18@bandit.labs.overthewire.org:/home/bandit18/readme .

  2. .bashrc包含exit 0,因此bash在您通过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
    

最新更新