The Elusive Command Alias Function? 114
Meph_the_Balrog asks: "I work as a helpdesk jockey for a company that manages over 1200 linux based servers, across a huge area. Currently we use a Windows SSH client to provide remote server support, and I don't have the weight to convince management to deploy alias scripts to all of the servers we support. I admit this question may seem frivolous to some, perhaps dangerous to others, so I have a twofold question. Do any of you out there use a Windows based SSH client that supports command aliasing? If you have strong objections to this sort of technology, what inherent problems do you see with it?"
Re:Huh? (Score:2)
Re:Huh? (Score:2)
That's exactly right. With a bit of boilerplate VisualBasicScript, I've automated the logins to all the systems I work on.
I could, if I needed to, add as
Re:Huh? (Score:2)
Huh? (Score:1)
I get what he wants. (Score:4, Informative)
He has no power to install his favored command aliases on all of the machine he has to administrate. He wants to have an SSH client (that he can run on Windows to connect to the Linux machines) that will interpret what he types and substitute aliases so that he doesn't have to set up his favored commands every time he logs into a system.
I don't know if you can set an SSH session into a line-based instead of keystroke-based communication mode. By default, it sends messages to the remote server after every keystroke and not after enter is hit at the end of a line -- otherwise using curses-based applications would really, really hurt as would using tab-completion, vi mode, and other advanced shell features. If this can't be done, then a client couldn't interpret your commands before you send them.
I don't forsee anyone providing this functionality because the demand is so low. This is the kind of thing that the remote end is expected to handle for you.
Re:I get what he wants. (Score:2)
alias ls="ls -alF"
alias nano="nano -w"
2) Open connection to server in client of choice
3) Open file in notepad
4) Select All
5) Copy selection
6) Paste in connection window
Re:I get what he wants. (Score:2)
8) Sob yourself to sleep after tearing out all hair.
Re:I get what he wants. (Score:2)
This is a really easy problem to answer. Follow these steps in order:
1. Make a list of all the servers and put it in a text file.
2. Make your
Re:I get what he wants. (Score:2)
Whoops, I meant:
Re:I get what he wants. (Score:1, Informative)
sh: command line to long
Not that many servers in your data-center, are there?
Try
while read server; do scp
(because I wouldn't want my username duplicated for every server in the serverlist and I tend to avoid using cat without reason).
Why anyone would use bash though is beyond me. My advice: Use something that you know will always be available by default, not something mostly used by Linux-users.
Re:I get what he wants. (Score:3, Informative)
I am all too familiar with his conundrum, especially when it comes to being forced to work with inferior tools. I work in an environment where I am responsible for keeping production systems running, and I don't have admin install privileges. Even our admins don't have the political power to change things without serious pe
Re:I get what he wants. (Score:2)
Re:I get what he wants. (Score:1, Insightful)
Problem is, I happen to like vi-mode bash (set -o vi) but everyone would kill me if I put that in a
Ya dig?
Re:I get what he wants. (Score:2)
Not sure about the original poster, but we're doing (voluntary) Sorbanes-Oaxley compliance. I'm not even allowed to LOGIN to the production environment unless I submit a plan of work I intend to do, including risk, ways to avoid them, backup plan, concurring business stakeholders, etc etc. There is
Re:I get what he wants. (Score:2)
If he has a user-level account on the box, then he has permission to do what I wrote. And if he doesn't have a user account on the box, then how would he login in the first place. None of the stuff I asked him to do requires root.
Re:I get what he wants. (Score:3, Insightful)
1) He doesn't have permission to modify his own user account. Unlikely, but possible -- especially if
2) He's got to use several shared administrative accounts (like root or various accounts for specific services), or the account he has
Re:I get what he wants. (Score:2)
Re:I get what he wants. (Score:3, Interesting)
However, I have a STRONG aversion to lots of aliases, particularly for someone learning systems administration. When I first started using unix, the sysadmins in the Engineering department had set up a bunch of DOS-like aliases on our servers, so we would feel more at home. We came to depend on these, and a
Re:I get what he wants. (Score:1)
ROTFLMAO. Since when has a comp sci degree required a higher gpa then an electrical engineering degree.
Re:I get what he wants. (Score:2)
Have your home environment in CVS on a box somewhere. When you first log in to a machine that you know you will be doing some work on, say more than a ten minutes clean up job, you do a cvs check out
What do your servers support? (Score:2)
`lynx -source http://someserver.com/with/my/script [someserver.com]`
(note the backticks) when you first log in.
Re:What do your servers support? (Score:2)
With a bit of (bad) luck, he'd be running that script as root... *shudder*
Re:What do your servers support? (Score:2)
The same thing that would happen if someone else ever had write access to a special ssh client binary you use, or even to your local configuration files: he'd then be able to take over any account you logged into. If you have reason to think your ssh client computer is more secure than any file service you can write to, you don't have to paste a "run this alias script" command, you can just copy and paste t
Re:What do your servers support? (Score:2)
At least make it something like `ssh me@someserver cat
Re:What do your servers support? (Score:1)
Sort of clever, but it'd be infinitely easier and more efficient to put that in a network drive, then put ". /mnt/thatthingy/etc/aliases.sh" in their ~/.bash_profile. Pulling the thing with Lynx is kind of silly.
Re:What do your servers support? (Score:2)
I agree, but the requirement that you can't install your script on the servers you administer is pretty weird to begin with. If he's not allowed to install a script, he probably isn't supposed to edit
Why not.... (Score:2)
Re:Why not.... (Score:1)
Re:Why not.... (Score:2)
You ssh to your account, your
Re:Why not.... (Score:1)
Re:Why not.... (Score:2)
Submitter: SecureCRT from VanDyke Software (about $90 if I remember correctly), will support login scripts. That would solve your problem nicely.
If you can't afford that, or aren't allowed to install it,
Re:Why not.... (Score:2)
You ssh to your account, your
In many large production environments, especially in systems that fall under SOX 404 restrictions, people don't have write access to their home directories. Often they have
eh? (Score:1)
Replicated ssh commands (Score:1)
If you want to get really funky then add interaction to the script to allow inputing commands. If you are actually messing with multiple machines I submit it
Re:Replicated ssh commands (Score:1)
I marvel at people that do not realize that man pages are worth a read.
Go RTFM!
Paint me Confused... (Score:2)
Re:Paint me Confused... (Score:1)
sure he could probably go and do it unilatterally, but thats a move that doesn't have alot of CYA in it. CYA is alot more important in some places than others.
That said its not all about CYA, sure change management processes are often slow, and tedious, and often seem pointless for small changes.... but... nobody ever made a system problem worst
Re:Paint me Confused... (Score:2)
Now, he has to work within the structure. And, within the structure, scripts can probably be deployed.
Of course, making a script that enters from the keyboard via an SSH client playback macro so it doesn't have to go through the run-book is... kind of borked, no?
If he DIDN'T have write access and was simply collecting information, such a dynamic script may be justified.
If he wants to use this to introduce another management layer without
Re:Paint me Confused... (Score:2)
Re:Paint me Confused... (Score:1)
I sort of assumed that it was more an issue of looking for a solution for a team of admins. You know... like I can put the cool tools I like in my home dir on all the machines I touch, but installing it for everyone else to use requires aproval.
Also, ssh macros shared on a team seems fine to me. Its still only triggered when an admin is using it, and its not installed on the machine. Nobody has to go in as root and start pushing files around (or tell the distribution engine to push it out to the machine
What kind of aliases? (Score:3, Insightful)
I'm guessing from the mention of Windows that you're thinking of things like:
alias del='rm'alias dir='ls'
Hard to say with such a vague question though, especially with the idea that the client must support the aliases. The clients I've used terraterm and PuTTY are the most commonly used, and putty at least doesn't support aliases. (Can't recall terraterm using them either, but I admit I didn't use it often).
Personally I think that having DOS-style aliases is a mistake. Even though they might seem helpful to users of DOS/Windows it can cause problems when people realise the commands, even aliased, don't work in the way that they'd expect.
Unless you could offer a 100% compatible environment it would be best to let people realise that Unix is different and work with it as it should be.
Re:What kind of aliases? (Score:2)
> Unless you could offer a 100% compatible environment it would be best to let people realise that Unix is different and work with it as it should be.
Perhaps I don't understand what you are saying, but how would it cause problems that don't already exist? If it is a case of people not understanding UNIX vs. DOS, it would be people not understanding aliases v. not understanding the UNIX com
Re:Amateur! (Score:2)
Not that kind of aliases (Score:2)
alias h='history | grep -i'
alias nmap='nmap -v -O -sS'
Now, he doesn't want to have to login to 1200 different machines and edit 1200 different
Re:Not that kind of aliases (Score:1)
The way you read the question seems to make more sense than the way I did.
I'm not sure really how to handle this situation then.
If the OP doesn't have permission to script the copying of some files to /etc/bash_completion.d/, or similar, I guess the question comes down to scripting the addition of the macros on all the client machines via a login script, or some other Windows-magic
That might work out nicely if the users are all in a single Windows domain.
I find the idea, though, of macros for SSH access
Don't think so (Score:2)
Re:Don't think so (Score:2)
I think the problem with that is that he wants a solution across multiple servers and multiple users. IMWO, I would guess he needs a SSH client that will automatically send a list of commands (contents of your suggested script, from some a central location) after the user is authenticated. But he would have to ensure evereyone's SSH client ran those commands. So I guess it's not a solution at all, unless he could force all of 'his' client
Re:Don't think so (Score:2)
Re:Don't think so (Score:2)
Yeah, I remembered NFS just after posting, but didn't want to reply to myself. Even though he'd still need to go through all the paperwork, it might still be a good idea for his situation.
Re:Don't think so (Score:2)
Re:Don't think so (Score:2)
No, he just needs to run ssh under one of the standard pty programs like "expect" that can send a few commands for him after he logs in. Then he can do the scripting on his end, setting up aliases and whatever, and not have it affect any other users who log in with that account.
I'd do it by keeping a regular
'alias scripts' ? (Score:2)
So... an alias is something you either set on the command line, or in your shell startup scripts. it's usually
Bad idea... here's why (Score:2, Funny)
I've only watched one episode of Alias, but it didn't really draw me in. But, irrespective of that, I don't know why you'd want to put the scripts to copyrighted shows on your servers, especially if they are publicly available.
Maybe it's a Linux thing? people just want to do everything on Linux =-)
what are you asking? (Score:3, Informative)
ruptime=`ssh $1 '/bin/uptime'`
Then when you want to check the uptime on a remote box, you run:
ruptime remote_host
And do all this from a Windows box?
If that's the case, you should use Putty. The Putty configuration can be set up to run a remote command, linked to a given hostname. Then when you open Putty, just select the proper 'alias' from the list, just like you would any host.
I would expect SecureCRT has a similar function, but I haven't used it in a few years.
Re:what are you asking? (Score:3, Informative)
When you're editing the properties of a session, you can check the "Logon script" box and choose a logon script to use for that session. You can do that either per-session, or as a global setting so it happens for all of your sessions.
Your logon script can contain as many aliases as you'd like.
Re:what are you asking? (Score:2)
huh? (Score:1)
what i can tell you want is a client that will read "dir" as you type it in and on the remote machine run "ls -lh" or something. i have never seen anything that would allow you to do that.
i see no way of setting aliases without deploying it locally to each server, unless you have a roaming home directory.
Re:huh? (Score:2)
If it were telnet, a MUD client (eg, GMud) would do what he wants. However, I do not know of any SSH MUDs.
bleh (Score:3, Funny)
do you guys think i should wear a blue shirt tomarrow? ive heard alot of people like blue shirts but i was curious if anyone knew of any problems wearing blue shirts?
Re:bleh (Score:2)
I Hear Mauve has more RAM
Re:bleh (Score:2)
Blue shirts should be fine. We have however had some problems reported by staff wearing red shirts. They keep getting sent to die at the hands of aliens. Keep this in mind when planning your wardrobe.
Re:bleh (Score:2)
Blue shirts are teh suck. Any noob 1D10T knowz that!
Ask Slashdot Answer:
Huh? Wear a shirt? Why would you want to do that? We need more information. Where do you work? What is the dress code where you work at? Are you trying to impress anyone in your office? What size shirt do you wear? Do you know how to tie a tie? God. The stupid fucking quesitons have to stop! If you're going to ask us a question, give us all of the information. Maybe we can think of a solution you didn't.
For examp
Not aliasing but multiple command multiple servers (Score:1)
Re:Not aliasing but multiple command multiple serv (Score:1)
ex. (get the hostname from 4 different computers)
#mpiexec -n 4
fred
frank
fluffy
twirl
This is most likely very overkill for what the author wants tho.
Absurd question (Score:2)
Good idea (Score:2)
But I see no benefits of staying on Windows. Bottom line: switch to Linux or BSD like everyone else managing multiple remote servers and reap the benefits. It's as simple as:
$ ssh remote.host "cd
How about keyboard macro recording/playback? (Score:2)
That, by itself, could be a strong case for allowing an approved subset of aliases on your set of supported servers. Demonstrate a case where a simple typo could be catastrophic.
Typically, however, those aliases are resident in the shell local to the server, not in an ssh client (which usually provides pass-through access to the shell
Re:How about keyboard macro recording/playback? (Score:2)
What the heck do you mean with an "alias"? (Score:2)
command="/some/script/or/something.sh" ssh-rsa user@host
Clarification (Score:1)
Since I work in a corporate environment, my choice of workstation operating system is well beyond my control, even more so than my ability to deploy command aliases to each individual server. I'm also on helpdesk, so I have no direct administrative access, just a limited shell account that is shared between myself and 5 other techs. I could try and make a business case for command aliases being deployed to all the servers, but as a helpdesk t
Re:Clarification (Score:2)
Re:Clarification (Score:2)
On the other hand, I have leared to stop worrying and love the vi mode.
Don't use Putty to ssh to nix boxen (Score:2)
Not that I've tested this... (Score:2)
</lame>
What he seems to be looking for... (Score:1)
copy/paste (Score:1)
leave a notepad window open with the alias commands selected if you do it a lot.
Actually it seems like he is looking for is.... (Score:1)
Re:Actually it seems like he is looking for is.... (Score:1)
Re:Actually it seems like he is looking for is.... (Score:1)
Well, if this is the case, then just find a similar approach to some of the other suggestions...
Once set up, step 3 should only be one extra click to save time and effort.
Or even better... (Score:2)
That way you don't need to worry about flaky cut/paste buffers.
(If you don't have a home directory because you're logging in straight to the root ID, then the sysadmins are clearly a bunch of idiots.)
Re:Actually it seems like he is looking for is.... (Score:3, Informative)
What he's looking for.. (Score:2)
Cut & Paste (Score:1)
1. Put all your alias commands in a text file on your Windows machine
2. After you log in to a machine, paste the text in at the prompt
Sure it's a pain, but it works. You could even put in something like:
Then paste that in and press Ctrl+D. That way, it will put in the aliases each time you log in to that machine. If you don't see the message that says "No Aliases Required", then you know you need
Do it in the remote shell. (Score:2)
First of all, if you can possibly find a way to create your aliases within the shell of the remote machine, do so. There are two reasons:
1 - Only the remote shell knows enough about the context of your input to interpret aliases reliably. Your ssh client will be flying blind, and trying to get something that's functiona
Alias Bad. Function Good. (Score:1)
If you're using a shell that supports functions (i.e. bash), then you can get a lot more functionality by defining functions in your
Client-side:
Most SSH clients (i'm sure i'll get corrected) will not pre-process
What about cygwin on your windows desktop? (Score:1)
Re:What about cygwin on your windows desktop? (Score:2)
Hmmm. I've always thought of aliases and variables as very different sorts of beasts. Is there a way to manipulate aliases as though they were environment variables? (In one of the common shells?) Sounds like it could be a handy trick.
The proper way to do this. (Score:1)
1) Cygwin
2) Dedicated Shell Server
Within this environment you will use fanout [stearns.org] from Bill Stearns [stearns.org]
A) If the remote systems are not set to ``UseLogin yes'' in sshd_config then the custom environment can be used with environment='whatever=whatever' in the remote ~/.ssh/authorized_keys. This, of course, would also require a key which may not be possible as well as ``PermitUserEnvironment yes'' set in sshd_config.
B) The env channel from the ssh client can set the environm
How about using expect? (Score:1)
http://expect.nist.gov/ [nist.gov] for Expect and some usage examples
http://tcl.activestate.com/ [activestate.com] for Expect for Windows
Just define all the convenience functions you need as simple expect scripts and don't look back. If you like GUIs add some trivial Tk code.
expect (Score:2)
I don't know expect, but the script will probably look something like this:
Server Managment Software (Score:1)
Can you create a file on the remote machines? (Score:2)