I'm a beginner in Linux, using Ubuntu.
I want to make it easier to login to a server using ssh.
In my institute, our login command is
ssh -Y -p 4022 firstname.lastname@example.org.
How can I make an alias for this?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Add this to your
~/.ssh/config file (or create the file with this content):
Host cuplogin2 User user Hostname cuplogin2.ibs.re.kr Port 4022 ForwardX11Trusted yes
Now you can login using:
If you want, you can also shorten the name next to
Host if you want, e.g.
Host cl2. Then, you can login using
Quick answer You can add aliases into
~/.bashrc. This is the file used to initialize environments when you open a terminal. So you should add the following command into
# ssh alias alias sshmein='ssh -Y -p 4022 email@example.com'
Do not forget the dot "." before filenames. You need to open a new terminal/ssh for the changes to be applied.
Moreover, if you ever opened
~/.bashrc, you might find the following thing at the end:
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
which means all things in
~/.bash_aliases will be "included" into
~/.bashrc. So I always put my customized commands under
~/.bash_aliases. This is the neater way.
.bashrc can do many other things, for example
# extra PATH PATH="$PATH:$HOME/Android/Sdk/platform-tools" # joke commands alias please='sudo'
If you want to apply some alias system-wide, edit
/etc/profile, which is the
.bashrc for all users.