Score:0

Is there a way call an alias without separating it from previous characters?

tr flag

Super new to all of this. Trying to do the overthewire wargames to learn and thought it was a bit tedious to log in to each level, and wanted to make some shortcuts. I made an alias that can take the password for the next level and pass it through via sshpass which saves a good bit of typing. But I'm wondering if I can do the same for the connection address.

So far I turned this:

sshpass -p `sed -n "$p" banditpw` ssh <username>@bandit.labs.overthewire.org -p 2220

into just this:

sshp <username>@bandit.labs.overthewire.org -p 2200

I was wondering if I could do the same for the bandit.labs.overthewire.org -0 2200 part. I tried doing

alias otw="bandit.labs.overthewire.org -p 2220"

Which the terminal can recognize until I try to do this:

<username>@otw

It doesn't recognize I want to call the alias "otw" because it's unbroken from the @. Is there a way to get the terminal to understand I want to call an alias when it's not broken apart from the previous characters?

Also, I would just include the username@ in the alias, except that the username changes each level.

hr flag
For the specific case of ssh commands, an entry in your `~/.ssh/config` file will be much more expressive than anything you can achieve with an alias
Score:0
ro flag

I think you want to login with something like that

$ user1@otw
$ user2@otw
$ user3@otw

I purpose to use function to login with something easy like that:

$ otw user1
$ otw user2
$ otw user3
  • to make this function, you can do:
otw(){
user="$1"
sshpass -p `sed -n "$p" banditpw` ssh ${user}@bandit.labs.overthewire.org -p 2220
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.