date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,486,900,441,000 |
Without Oh-My-Zsh, I can pushd two identical path:
$ dirs
~
$ pushd Desktop
Desktop ~
$ pushd ~
~ Desktop ~
With Oh-My-Zsh:
$ dirs
~
$ pushd Desktop
Desktop ~
$ pushd ~
~ Desktop
How do I disable this? I want the original Zsh behavior.
|
(Insprired by this answer) It is set in $ZSH/lib/directories.zsh:
setopt auto_pushd
setopt pushd_ignore_dups
auto_pushd makes cd behave the same as pushd. However, this would result in an directory stack overflow if you keep changing directory, so they set pushd_ignore_dups as well, to limit the stack. This is not a ... | Oh-My-Zsh remove duplicated path in directory stack |
1,486,900,441,000 |
For context, I'm using zsh. Every time I use locate, I want to pass the -i and -A flags.
Usually, if I can get away with it, I create an alias with the same name as the existing command to do this. But according to this question, aliases can't accept arguments, so I have to use a function instead. Usually I stop there... |
I am really surprised by that other post you mentioned, as it can be very misleading. Just because an alias doesn't use parameters doesn't mean that aliases cannot set parameters. Of course you can put options in an alias, but it is just restricted, meaning, the alias is replaced in one place.
$ alias ls='ls -l'
$ l... | How can I/Should I default flags when running a command? |
1,486,900,441,000 |
I have looked for a solution to this OhMyZSH! problem for a few days now, but can't find a solution.
Admittedly, I do not understand how zle really works, same for bindkey. Same goes for the way terminal emulators send "control sequences", and what the "terminal type" means (xterm, versus xterm-256-color, and others).... |
You must configure your terminal type as putty, putty-256color, or putty-sco when using PuTTY. They are the only terminal types whose entries in the terminfo database correctly describe PuTTY.
It is a widespread incorrect assumption that terminal emulators are all compatible with XTerm, and that the xterm and xterm-2... | Using putty, Left and Right keys move cursor one word, instead of one char |
1,486,900,441,000 |
function projectopen {
local di_files=(*.xcworkspace */*.xcworkspace *.xcodeproj */*.xcodeproj)
# open first exsit file
ls -d -f -1 $di_files 2>/dev/null \
| head -1 \
| xargs open
}
I write a shell function to quick open xcworkspace in terminal. But when I declare di_files as a local var, then ... |
In older versions of zsh you cannot initialise an array with local (or typeset/declare) like that, you need to separate it, e.g.
local -a di_files # explicit array
di_files=( ... )
The feature to permit declaration and array assignment together was added in v5.1.
I believe the error you see is because zsh is treating... | Declare as local var will break a function and log out "1: number expected" |
1,486,900,441,000 |
I am using zsh in Babun (Cygwin with oh-my-zsh and some extras).
I noticed some odd behavior, it looks like cd is behaving like pushd?
{ ~ } » mkdir foo
{ ~ } » pushd foo
~/foo ~
{ foo } » popd
~
The above is fine and expected, but see the below.
{ ~ } » cd foo
{ foo } » dirs
~/foo ~
I tried checking if there w... |
I see now. oh-my-zsh does setopt auto_pushd which is described here as:
AUTO_PUSHD (-N)
Make cd push the old directory onto the directory stack.
| Why is cd appending dirs like pushd? |
1,486,900,441,000 |
I have an ever-expanding .zshrc file that was getting out of hand so I decided to try to fix it by breaking it into modular files and sourcing each of them. This works for the most part, but I seem to have some scoping issues related to variables.
Each module file contains a function matching corresponding with the n... |
Your functions will see the variable that you have set earlier (and exported or not) provided they haven't been set in a subshell or not declared local to some function that has since returned.
Your problem comes from unrelated mistakes in your code:
for config_file ($ZSH_CUSTOM/*.zshrc(N)); do
# Skip self-inclu... | Variable Scope in ZSH: How to access global variables from within function? |
1,486,900,441,000 |
I've installed Arch about a week ago, and since then I been struggling with the powerline fonts. But after installing the pkg powerline-fonts, I configured the .zshrc file by adding these lines:
powerline-daemon -q
. /usr/share/powerline/bindings/zsh/powerline.zsh
The best I could do is commenting the line in the .... |
Good Ol' Locale
One issue I have had come up is not having my locale set, which causes all sorts of headache and misery to befall the unaware. To set it, go to /etc/locale.gen and uncomment the US English locale: en_US.UTF-8 UTF-8 then as root run locale-gen and as root again localectl set-locale LANG=en_US.UTF-8 jus... | How to fix powerline fonts and symbols error in shell? |
1,486,900,441,000 |
(I originally posted this on apple.stackexchange but then I found this one which is probably a better place)
I have a big problem. I've freshly installed mac os and was setting up my terminal. I installed iTerm, zsh and oh-my-zsh (following this tutorial, basically: https://medium.com/ayuth/iterm2-zsh-oh-my-zsh-the-mo... |
The problem is caused by iTerm having problems with the first beta version of Mac OS Big Sur. A specific setting causes the problems I've experienced. See https://gitlab.com/gnachman/iterm2/-/issues/8965 for details.
Until fixed, the workaround is this (taken from the GitLab issue):
Workaround:
Disabling Enable sessi... | terminal stuck at “login” - blank screen (after installing oh-my-zsh, I think) |
1,486,900,441,000 |
Oh-my-zsh has a plugin option (plugins = (gcloud, ...)) which allows installing gcloud completions.
When I add "gcloud" to plugins, I expect that the completion will be sourced during shell initialization, but it doesn't work on NixOS (version 19.03).
How to install gcloud completions on NixOS with oh-my-zsh?
|
Instead of adding gcloud to programs.zsh.ohMyZsh.plugins, I found that I had to manually source the completion script. To do this:
Add pkgs.google-cloud-sdk to environment.systemPackages of your configuration.nix file, and then update the zshrc section:
programs.zsh.promptInit = ''
export CLOUD_SDK_HOME="${pkgs.goog... | How to install Google Cloud completion in NixOS with Oh-My-Zsh? |
1,486,900,441,000 |
I got an image from Facebook which is beautiful i want to make my Arch Linux machine just like this image,
I have installed Arch Linux with Deepin Desktop Environment also installed neofetch, i am stuck on zsh shell theme which you can see in image, i tried to search in oh-my-zsh repositorieshttps://github.com/robby... |
Try this below instruction:
first list all the install shell in your current system:
chsh -l
then change your shell like this: (in your case zsh:
chsh -s /bin/zsh
and now restart or logout and login.
then install oh-my-zsh theme from here :
https://github.com/robbyrussell/oh-my-zsh
installation command looks like:
s... | Which zsh shell theme is this? |
1,486,900,441,000 |
I have recently re-installed ubuntu 14.04 lts and I installed my favorite shell (zsh) but I am having an issue now.
When I type, sudo su it comes back with an error stating /root/zsh can not be found.
I am not sure what I need to do to fix this as this is the first time I have had this error when using this system.
Al... |
su executes your login shell as indicated in the login database. This is /root/zsh, which doesn't exist, so the command su fails.
chsh only accepts changing the shell of a user who currently has a valid shell (listed in /etc/shells). Since /root/zsh is not accepted, chsh fails. The root user can change anyone's shell,... | Sudo su issue on ubuntu 14.04 lts: /root/zsh can't not be found |
1,486,900,441,000 |
I am new to zsh and I like it a lot, especially with oh-my-zsh plugin. I installed oh-my-zsh with its default values and can't figure out how to turn off autocompletion for specific commands, that I often use, such as:
sudo mc or sudo gem update. The thing is that I have .mc directory and .gem directory and zsh propos... |
Ignoring directory patterns is fairly painless. You can add the following to your ~/.zshrc.
The first line ignores .mc and .gem patterns after issuing cd [TAB]. The next line ignores them after issuing sudo [TAB].
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#.mc' '(*/)#.gem'
zstyle ':completion:*:sudo:*' ignored... | How to disable autocompletion for sudo ...? |
1,486,900,441,000 |
Why will this
bindkey '^ ' end-of-line
works, and accept the suggestion, but
function accept {
zle end-of-line
}
zle -N accept
bindkey '^ ' accept
this won't work.
I don't understand why. I also tried to replace end-of-line with autosuggest-accept in the function, but still nothing happens...
What I try to do is ... |
When a keybinding’s widget is activated, the Zsh Line Editor (ZLE) sets the $WIDGET parameter to the name of the activated widget.
In turn, zsh-autosuggestions checks whether the value of $WIDGET is a member of $ZSH_AUTOSUGGEST_ACCEPT_WIDGETS. If so, it will accept the suggestion.
However, inside your widget function... | end-of-line widget not working in functions (zsh-autosuggestions) |
1,486,900,441,000 |
I'm modifying the intika2 theme in oh-my-zsh to add the current pyenv setting to my prompt. OMZ includes a pyenv_prompt_info command & I added it to the LEFTINFOS variable in the intika2 theme to do this. This provides the correct pyenv version whenever the .zshrc file is sourced, but not on subsequent prompts after c... |
You have the wrong quotes. The definition of LEFTINFOS uses double quotes, so what's inside the quotes is evaluated when the definition is evaluated, instead of when the prompt is calculated. You need to arrange for the value of PROMPT to contain the string $(pyenv_prompt_info). So define LEFTINFOS to contain $(pyenv_... | oh-my-zsh prompt substitution |
1,486,900,441,000 |
When I open a new terminal it takes a couple seconds for the shell to load, when I open a new pane or window in tmux it might even take a second longer. The delay is about 3 seconds.
I'm using zsh with oh-my-zsh and the ohmyzsh plugins: git, vi-mode, history-substring-search.
My path looks like:
/home/alec/.nvm/vers... |
Add: set -x to the top and set +x to the bottom of ~.zshrc to get a lot of output about what's being run during shell startup. (It's helpful to keep that file open in a separate window/terminal/editor during the whole debug process)
It can be hard to know what's proper and what's problematic among all that output... ... | why is shell (new terminal, new tmux panes/windows) slow to load? |
1,486,900,441,000 |
So I installed zsh a few days ago, and I'm loving it. But when I type something in, it shows me the possible completion using the autosuggestions plugin, but I cannot fill it using tab, i have to use the arrow keys. Pressing tab opens a menu of possible completions and/or a list of subdirectories and files. I want to ... |
You can unload the completion system completely like this:
zmodload -u zsh/compctl zsh/complete
bindkey '^I' forward-word
Instead of inserting completions, Tab will now accept the next word from zsh-autosuggestions.
Before you give up completely on completions, though, may I suggest you give my zsh-autocomplete plug... | How to disable all menu tab completions in ZSH. I have the zsh-autosuggestions plugin installed, and i want that to be the only form of completions |
1,486,900,441,000 |
I constantly need to close and re-open programs. To do this I press Control+C > Up Arrow > Enter. However, I have more than one program and need to run different commands for these programs. If I run another command in a new terminal the history changes for the original terminal and the up arrow is no longer the last ... |
There was a comment that was deleted that explained that Bash did not exhibit the same behavior. That great comment helped me find How to make oh-my-zsh history behavior similar to Bash's?.
I updated ~/.profile with:
bindkey "$terminfo[kcuu1]" up-line-or-history
bindkey "$terminfo[kcud1]" down-line-or-history
Which h... | Run the same command |
1,486,900,441,000 |
I am trying to execute the gpustat command after SSHing into a remote server.
I am using z-shell + oh-my-zsh.
I put the gpustat command into my .zshrc file.
However, after logging in, I get the error message:
command not found: gpustat
What I find confusing is that when I source the .zshrc file, the gpustat command... |
It looks like you're trying to run gpustat in your .zshrc file before it has been added to your $path. My guess is that its added to your path somewhere later in your .zshrc, which would explain why it works when you source your .zshrc file manually: At that point, your whole .zshrc file has already been sourced once ... | zsh - run gpustat command after login |
1,486,900,441,000 |
First, let's assume that I have:
alias foo='path/to/my/program'
in my .zshrc, then I created a completion script ~/.oh-my-zsh/completions/_foo for it, where inside the file I have:
#compdef foo
_foo() {
echo "hello"
}
_foo
So, I expected that when I type foo [tab] from shell I will see
$foo [tab]
hello
but in... |
This is an answer about zsh in general. I don't know oh-my-zsh.
By default, zsh expands aliases before attempting completion. This is usually the right thing. As a consequence, associating a completion function to the name of an alias only has an effect when you bypass the alias, for example after \foo Tab.
You can tu... | Zsh completion script found but not executed |
1,486,900,441,000 |
Is there a way to remove the trailing forward slashes in the tab-completion output of Zsh when I start writing a cd command and tab to see a list of directories?
E.g.
~ cd <tab>
Adlm/ Desktop/
Applications/ Development/
I was wondering if there's any way to remove the slashes afte... |
In zsh, it's:
set +o list_types
When using complist, you can also change its color to make it less visible:
zstyle ':completion:*' list-colors tc=33 ${(s.:.)LS_COLORS}
to make it yellow (less visible on a terminal with white background), and use the GNU ls colors (assuming you've run eval "$(dircolors)") for the re... | Remove forward slash when tabbing to see a list of directories |
1,486,900,441,000 |
I'm using zsh on MacOS El Capitan. I'm wondering how auto completion has to be parameterized to resolve aliases as well.
When I used bash, my .bash_profile contained the following:
alias mdb "mongo -uadmin -pXXX --authenticationDatabase admin --host "
complete -W "$HOSTNAMES" mdb
HOSTNAMES is a list of over 4000 FQDN... |
I found a solution which works exactly as I wanted. Only the following three lines are required in .zshrc:
mdb() {mongo -uadmin -pXXX --authenticationDatabase admin --host "$@"}
compctl -k "($(echo $HOSTNAMES))" mdb
zstyle ':completion:*:(ssh|scp|sftp|host):*' hosts $(echo $HOSTNAMES)
The function mdb() replaces my f... | How to use aliases with auto completion in oh-my-zsh? |
1,486,900,441,000 |
Today my server slowed down greatly. Most resource-consuming are - surprisingly - two shells. Two ZSH processes on TTY 0 (what does that mean?).
> ps axjf
12474 8947 16532 16532 ? -1 Sl 1000 0:34 \_ /usr/bin/xfce4
-terminal
8947 8953 16532 16532 ? -1 S 1000 0:00 | ... |
Before I kill these, how to find out what are they doing?
strace them, for starters. In a pinch, use a debugger.
what does that mean?
It means that they have no controlling terminal. Given that they are children of XFCE Terminal (right there as /usr/bin/xfce4-terminal in your process tree), you should also look ... | What is this shell doing and how to find it out? |
1,486,900,441,000 |
I'm trying to setup zsh so that it autocompletes my rclone commands, for example rclone copy gdr <tab> and it becomes rclone copy gdrive-johnsmith while also doing the same thing to file names.
rclone did come with a command to generate a zsh autocomplete file, but the file did not autocomplete remote directory names... |
From reddit:
You can use _alternative to complete two sorts of things such as
directories and rclone remotes. For example, something like:
_arguments \
'3: : _alternative
"files:file:_files"
"remotes:remote:($(rclone listremotes))"'
The space before _alternative is important here to avoid _arguments
pa... | zsh shell autocomplete, how to autocomplete both files and arbitrary strings returned from a function |
1,486,900,441,000 |
I use oh-my-zsh configuration. When I want to auto-complete, I need to first type correctly the initial letter. For example
go, then tab will give google-chrome. If I type *le-ch*. It didn't work. How can I do that?
|
You can get that behavior by setting the completion style completer to include the _expand control function. This is what I use:
zstyle ':completion:*' completer _expand _complete _match _prefix
| Can I auto-complete by tab in zsh with regular expression |
1,486,900,441,000 |
I'm trying to use colors in oh-my-zsh themes. It works fine on my home computer (ubuntu), but in a work computer (Scientific Linux i.e. Enterprise linux) the prompt colors are actually spelled out. For example, my prompt using the blinks theme looks like this (note this ISN'T the code, this is what appears as my prom... |
Most likely the version of zsh you are using is from before the %F color escape sequence was added. This means that, in addition to not coloring the prompt correctly, it will leave the arguments to this sequence lying around. To solve this you should replace the current theme file with this:
function _prompt_char() {
... | Colors not rendered correctly in oh-my-zsh themes |
1,486,900,441,000 |
I installed zsh + oh-my-zsh in an archlinux environment.
after that ls command's output became like this:
How I can change folders' color ?
|
Those "ugly" colors are caused by two things:
The use of ls's --color option
Uncommon permissions (mode bits) of the files/directories that are displayed
Remedies:
Adjust the colors to your taste by setting/changing the LS_COLORS environment variable (see ls, dircolors and dir_colors manpages)
Fix your folder permi... | Solve ugly color in ls command |
1,486,900,441,000 |
I am running Arch Linux locally. When I connect to my remote Debian 10 server via ssh, the cursor behaves in an awkward way:
As long as every command returns statuscode 0, everything is fine. When another code is returned, the cursor and the right prompt are shifted to the left by 2 characters, as shown below. The fir... |
My locale was not set. I set it now, and it works!
| zsh-cursor displacement over ssh |
1,565,492,070,000 |
I want to change my PATH variable in zsh.
Problem: I don't understand where in the .zshrc file I have to make modifications.
Normally, I would look for the assignment to the PATH variable and set the values from scratch how I would like them to be (leaving all the systems binaries directories untouched).
The first lin... |
Re-posting from comments in to an answer, but with some extra notes.
First, search the web for introductory guides to working with the Un*x shell (command line) and terminal sessions. Most of them give a lot of information on the most common environment variables, such as PATH. (Some may not give a lot of detail on th... | Changing PATH Variable in zsh |
1,565,492,070,000 |
I need to set up a function in zsh that would edit a different file based on some input at the command line.
I want to simplify my aliases so I don't have multiple aliases to do the same thing but with a slight variation. I am specifically trying to set up a function to open in my editor different versions of the php.... |
function editphpini() {
local version=$( echo $1 | sed 's/^\(.\)/\1./' )
subl /usr/local/etc/php/${version}/php.ini
}
usage:
% editphpini 54
| ZSH function to edit a file based on an input at the cli |
1,565,492,070,000 |
How do i get this fancy "path bar with git icons" as shown in this picture of zsh?
What is it called?
|
This is a Zsh theme called agnoster, which works in conjunction with Powerline-patched fonts to display those symbols.
It’s available in Oh My Zsh.
| How do i get this fancy "path bar with git icons" as shown in this picture of zsh |
1,565,492,070,000 |
I was trying to use an alias which should run two commands, where the first is fine to be run with normal user privileges and the second one needs sudo privileges.
alias hosts-get="scp [email protected]:/etc/hosts /tmp/ && sudo cat /tmp/hosts >> /etc/hosts"
The usecase is to pull the hosts file of a remote server an... |
While the sudo command in your first alias provides root privileges for cat /tmp/hosts the redirection >> /etc/hosts will be tried with your user privileges.
As those usually are not high enough you get the 'permission denied' error.
To make this work, you can run the command in a subshell like this:
alias hosts-g... | Having sudo and non-sudo parts in an alias - why does it not work with >>? |
1,565,492,070,000 |
I have installed oh-my-zsh on high Sierra but cannot uninstall and return my terminal to standard bash.
I have used uninstall_oh_my_zshcommand, but still can see .zsh on terminal once open it!
can anyone help?
|
You should change your terminal to bash first using /usr/bin/chsh -s /bin/bash , then simply remove all zsh related files. Or use this Script to run it simply navigate to the script directory and do sh uninstall.sh
| remove oh-my-zsh |
1,565,492,070,000 |
I'm using zsh 5.0.2 (x86_64-apple-darwin12.3.0) on the latest MacOSX. If it makes any difference, I have also enabled oh-my-zsh.
The shell seems to be missing the .zshrc file when I want to source it.
The result of the execution of the following commands should expose my problem clearly. (~ » is my prompt).
The file e... |
The . command searches for the file in your $path, it does not by default search in the current directory. That is why it works when you give the absolute path ("$(pwd)"/.zshrc).
From the zsh manual about the . command:
. file [ arg ... ]
Read commands from file and execute them in the current shell environment.
If f... | Weird behavior when sourcing .zshrc |
1,565,492,070,000 |
I'm trying to limit the column width of the command column when running a ps command, but also trying to pipe that output into a grep command. However, this is not working.
This runs fine:
ps -eo pid,user,command:30
However, this:
ps -eo pid,user,command:30 | grep node
gives me this error:
ps: command:30: keyword n... |
Assuming sed supporting -E, limiting command to 30 characters:
ps -eo pid,user,command |
sed -E 's/^( +[^ ]+ +[^ ]+ +)(.{30}).*$/\1\2/g'
using awk, pid column formatted to width 6 (assuming the pid will have at most 6 digits), user column formatted to width 10, command to 30:
ps -eo pid,user,command |
awk '{
... | Using grep with ps and column width specification |
1,565,492,070,000 |
I just installed oh-my-zsh. Things worked fine. Then I tried commenting out export ZSH="~/.oh-my-zsh"
After this, when I uncommented the line back, I keep getting the below error. However, "oh-my-zsh.sh" is present
(base) abc@def-MacBook-Pro .oh-my-zsh % source $ZSH/oh-my-zsh.sh
source: no such file or directory: ~/.o... |
That's because ~ is not expanded to the value of the $HOME variable when you quote it (with any type of quoting mechanism including single, double quotes, backslash, $'...').
Thus you can use these commands instead:
export ZSH=~"/.oh-my-zsh"
or
export ZSH=~/.oh-my-zsh
or
export ZSH="$HOME/.oh-my-zsh"
Note that nor... | oh-my-zsh No such file or directory even after installation |
1,565,492,070,000 |
I just installed ZSH on a remote server where we are 2 "admins".
I switched my default shell to ZSH with chsh -s $(which zsh). echo $SHELL gives the output /usr/bin/zsh which proves it.
But, when I open my ssh session I receive an error like:
/etc/profile.d/vk.sh:30: command not found: shopt
This error appears only a... |
The /etc/profile file contains system wide profile settings. Within that file, many distributions are sourcing scripts within /etc/profile.d. Hence, all interactive logins will invoke what is in that folder. If you want a profile script to be scoped to one account, you have to either
move that script into ~/.profile... | Multi-user env, SSH ZSH - command not found: shopt |
1,565,492,070,000 |
I'd like to connect to a remote server using ssh and have the session running in Vi mode. I have found how to do that for bash:
ssh username@server -t 'bash -o vi'
But I need the same thing for zsh (oh-my-zsh, if that makes any difference). I can't find anywhere how to achieve this. I have tried "zsh -o vi" but that ... |
Once inside your shell, simply run
bindkey -v
Directly from ssh:
ssh -t username@server 'VISUAL=vi zsh'
| Run zsh (oh-my-zsh) in Vi mode when connecting to remote server via ssh |
1,565,492,070,000 |
Seems like history [number] is backward in zshell because it's using fc. How do I get history [number] to behave like it does in bash?
➜ exec bash
bash-3.2$ history 3
35 history 5
36 exit
37 history 3
bash-3.2$
➜ history 3
1 pwd
2 ..
3 mv work Documents
➜ history
3133 history 5
3... |
It wasn't as difficult as I thought it would be. Added this to my ~/.profile
# zshell aliases history to "fc -l"
# quick version
alias h="fc -l -50" # last 50
# history searching
function hg {
echo "Searching for '$1'..."
fc -l 0 | grep "$1"
}
Related and helpful: Show older or newer history items with the ... | How do I alias history 20 to work the same way in zshell vs. bash? |
1,565,492,070,000 |
I want an alias shortcut to achieve the following:
Clone a github repository with a custom folder name
Open it in my fav text editor (atom)
I currently use this inside ~/.zshrc:
alias quickstart="git clone https://github.com/myname/quickstart-html-template.git new_html_project && atom new_html_project"
Can I paramet... |
You can't define parameters in an alias, you need to use a function:
quickstart() {
git clone https://github.com/myname/quickstart-html-template.git "$1" && atom "$1"
}
Add that to your .zshrc instead of the alias definition.
| Using zsh alias to quickly clone a git repository with custom folder name |
1,565,492,070,000 |
When I type time + number in zsh:
# atupal at local in /tmp/atupal/setup/bin [10:01:49]
$ time 1
/tmp/atupal/setup/bin/lib/python2.7
# atupal at local in /tmp/atupal/setup/bin/lib/python2.7 [10:01:54]
$ time 2
/tmp/atupal/setup
# atupal at local in /tmp/atupal/setup [10:01:59]
$ time 3
/tmp/atupal/setup/app
# atupal a... |
oh-my-zsh creates a few alias in .oh-my-zsh/lib/directories.zsh named 1, 2 ... 9 which expand to cd -, cd -1, etc. So time is functioning correctly, but the unexpected alias 1 actually does something. The reason why time's normal output isn't given is due to the fact cd is a builtin command that doesn't require forkin... | zsh: What does the command "time + number" do in zsh |
1,565,492,070,000 |
I want to clear my shell history on every shutdown/logout.
I know how to clear the history manually, I know how to clear the history automatically, when closing the session/terminal emulator. However, this is not the intended behaviour.
I am using zsh on manjaro with wayland and sway.
I have tried using .zlogout. Howe... |
If you happen to use systemd (which manjaro should AFAIK), one option would be a simple service that just succeeds and has the history-deletion executed when it stops. Then make it depend on default.target:
[Unit]
Description=Delete zsh-history on logout/shutdown
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart... | Clear shell history on shutdown/logout |
1,565,492,070,000 |
I recently switched from bash to zsh in Fedora 38.
I have installed oh my zsh and have the following plugins.
plugins=(git fzf tig zsh-autosuggestions)
My terminal has been acting really weird. Part of it will disappear if I press up on the key pad and it has strange glitches when I paste stuff in with the middle mo... |
In your:
PROMPT='[%n]$fg[blue][%m]%{$fg[white]%}$(git_custom_status)[%~% ]%{$reset_color%}%B$%b '
While $fg[white] and $reset_color which presumably are the escape sequences that tell the terminal to change the foreground colour to white and reset the colours as defined by the colors autoloadable function are with... | Experiencing glitches on terminal Fedora 38 |
1,565,492,070,000 |
I tried to change the default zsh theme with oh-my-zsh from their github repository and I just edited .zshrc switching from the default theme to another one and it just somehow went wrong cause now I can't switch anymore and the theme stays the same even tho I'm switching to new ones.
I just wanna go back to the regul... |
If you're not an advanced user, beware that Kali does a whole load of things differently to usual. This is because it's targeted at experienced security professionals. That said, you should be able to get a fresh copy of .zshrc from the template directory /etc/skel
| Get back to default zsh theme in kali linux |
1,565,492,070,000 |
I am using zsh with oh my zsh and I wanted to get a thing like this:
How can I do it? I want a setting to put somewhere, so that whenever I restart my terminal and my system, it always displays the way a set it.
Thanks in advance.
|
PS1='%B%F{#ff1000}[%F{#d0b000}%n%F{#80f000}%b@%B%F{#00c0c0}%m %F{#ff80a0}%~%F{#ff1000}]%f%b$ '
Gives similar colour shades. Adapt to your taste.
%B: bold (%b reverts to non-bold)
%F{#RRGGBB} foreground colour specified with levels of red/green/blue in hexadecimal. (%f reverts to default colour). If your terminal doe... | Customizing hostname in zsh prompt |
1,565,492,070,000 |
In my ZSH custom config, I have this function:
cll() { ls -AlhG "$@" | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print}'; }
It outputs:
➜ test cll
total 32
644 -rw-r--r-- 1 work admin 0B Oct 7 18:55 .hidden
644 -rw-r--r-- 1 work admin 480B Aug 22 2016 ... |
Pipe it through the command cut -c 1-3,14-. tweak the numbers if you need to adjust it. Do man cut for more details.
| How to remove directory permissions from ls command piped through awk? [closed] |
1,565,492,070,000 |
When I use OMZ, I have a very, very nice feature I like to call context-sensitive history. It's easier to show than describe. If I run:
% abc
% cba
And then I type % a[up], without CS history I get% cba. With it I get % abc. What in OMZ causes this?
EDIT: I want this to give me results based on the beginning of the ... |
That sounds like zsh-history-substring-search, which according to the webpage is inspired by the fish shell (and offhand sounds like the way vi-like-emacs implements command history — there are probably several variations).
For other possibilities, see @jasonwryan's answer in How can I search history with what is alre... | Context-Sensitive History [duplicate] |
1,565,492,070,000 |
Any command I run (aside from clear) results in a double zsh prompt -- the first one showing the unformatted prompt, the second one showing the correct, formatted prompt.
My ~/.zshrc file:
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/... |
It turns out source $ZSH/oh-my-zsh.sh in the ~/.zshrc was causing some issues with Powerlevel10k. Commented this line out and the prompt went back to normal after quitting iTerm2 and opening it back up.
| Double zsh prompt is showing unformatted then formatted |
1,485,634,653,000 |
I am unable to ssh to a server that asks for a diffie-hellman-group1-sha1 key exchange method:
ssh 123.123.123.123
Unable to negotiate with 123.123.123.123 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
How to enable the diffie-hellman-group1-sha1 key exchange method on Debian... |
The OpenSSH website has a page dedicated to legacy issues such as this one. It suggests the following approach, on the client:
ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 123.123.123.123
or more permanently, adding
Host 123.123.123.123
KexAlgorithms +diffie-hellman-group1-sha1
to ~/.ssh/config.
This will ena... | How to enable diffie-hellman-group1-sha1 key exchange on Debian 8.0? |
1,485,634,653,000 |
I have two servers. Both servers are in CentOS 5.6. I want to SSH from Server 1 to Server 2 using a private key I have (OpenSSH SSH-2 Private Key).
I don't know how to do it over unix. But what I did on windows using Putty was to feed my OpenSSH private key to putty-gen and generate a private key in PPK format.
Howev... |
TL;DR: To use an existing private key inline you need to select the identity file path with the parameter -i as follows:
ssh -i '/path/to/keyfile' username@server
You need your SSH public key and you will need your ssh private key. Keys can be generated with ssh-keygen.
The private key must be kept on Server 1 and t... | How to ssh to remote server using a private key? |
1,485,634,653,000 |
I've read the official definition:
ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA, ECDSA). The idea is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program. Through... |
The SSH agent handles signing of authentication data for you. When authenticating to a server, you are required to sign some data using your private key, to prove that you are, well, you.
As a security measure, most people sensibly protect their private keys with a passphrase, so any authentication attempt would requi... | what's the purpose of ssh-agent? |
1,485,634,653,000 |
The ssh-keygen generates the following output:
The key fingerprint is:
dd:e7:25:b3:e2:5b:d9:f0:25:28:9d:50:a2:c9:44:97 user@machine
The key's randomart image is:
+--[ RSA 2048]----+
| .o o.. |
| o +Eo |
| + . |
| . + o |
| S o = * o|
| . o @.|
| . =... |
This was explained in this question: https://superuser.com/questions/22535/what-is-randomart-produced-by-ssh-keygen.
It doesn't really have any use for the user generating the key, rather it's for ease of validation. Personally. would you rather look at this: (Please note this is a host key example)
2048 1b:b8:c2:f4:7... | What's the purpose of the randomart image for user (not host) SSH keys? |
1,485,634,653,000 |
I know what it does, but I don't know why. What attack(s) does it prevent?
Is it relevant for all kind of authentication methods? (hostbased, password, publickey, keyboard-interactive ...)
|
The UseDNS option is mostly useless. If the client machines are out there on the Internet, there is a high chance that they don't have any reverse DNS, their reverse DNS doesn't resolve forward, or their DNS doesn't provide any information other than “belongs to this ISP” which the IP address already tells you.
In typ... | What is the point of sshd “UseDNS” option? |
1,485,634,653,000 |
I can't find my sshd logs in the standard places.
What I've tried:
Not in /var/log/auth.log
Not in /var/log/secure
Did a system search for 'auth.log' and found nothing
I've set /etc/ssh/sshd_config to explicitly use SyslogFacility AUTH and LogLevel INFO and restarted sshd and still can't find them.
I'm using OpenSSH... |
I have found the output of sshd and other core services in 'journalctl'.
See more at the Arch Wiki entry for systemd:
https://wiki.archlinux.org/index.php/Systemd/Journal
| Where are my sshd logs? |
1,485,634,653,000 |
Is there a way to structure a single command to login via SSH to a remote server and run a program on the remote login shell?
In the OpenSSH manual, it reads "If command is specified, it is executed on the remote host instead of a login shell." So, for example, ssh user@server mail will login to the remote server, dis... |
Have you tried ssh -t user@server "mail && bash" (or replace bash with whatever shell you like)?
The -t is necessary in order to create a pseudo-tty for bash to use as an interactive shell.
| Single command to login to SSH and run program? |
1,485,634,653,000 |
I'm using a Match block in OpenSSH's /etc/ssh/sshd_config (on debian) to restrict some users to SFTP:
# my stuff
Match group sftponly
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp -u 0002
ChrootDirectory %h
As you can see, I use a #my stuff comment in custom config files to easily ... |
To end up a match block with openssh 6.5p1 or above, use the line: Match all
Here is a piece of code, taken from my /etc/ssh/sshd_config file:
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no
Match host 192.168.1.12
PasswordAuthentication yes
Match all
X11Forwarding yes
X11Displ... | OpenSSH: How to end a match block |
1,485,634,653,000 |
I know how to connect 'to' a certain port using ssh.
ssh user@remotehostip -p XXX
Is there a way to establish ssh from the port which my local computer will be using?
|
That is not easily possible. How that can be done depends on where the source port shall be seen: Locally, too, or is it enough if it's the right port from the perspective of the external network?
You can run the SSH client in an LXC container. I have never done that thus I cannot explain it to you in detail. But you ... | How to connect ssh from a specified port? |
1,485,634,653,000 |
I've found that ssh-keygen ("ssh" package) produces different keys from puttygen ("putty" package).
If I create public and private keys with ssh-keygen some SSH servers will not accept my keys. If I create keys with puttygen only one server does accept it.
Why don't Linux repositories propose some common solution (pac... |
OpenSSH is the de facto standard implementation of the SSH protocol. If PuTTY and OpenSSH differ, PuTTY is the one that's incompatible.
If you generate a key with OpenSSH using ssh-keygen with the default options, it will work with virtually every server out there. A server that doesn't accept such a key would be anti... | What is the difference between an OpenSSH key and PuTTY key? |
1,485,634,653,000 |
I am trying to ssh to remote machine, the attempt fails:
$ ssh -vvv [email protected]
OpenSSH_7.7p1, OpenSSL 1.0.2o 27 Mar 2018
.....
debug2: ciphers ctos: aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: [email protected],[email protected],[... |
The -cbc algorithms have turned out to be vulnerable to an attack. As a result, up-to-date versions of OpenSSH will now reject those algorithms by default: for now, they are still available if you need them, but as you discovered, you must explicitly enable them.
Initially when the vulnerability was discovered (in lat... | ssh Unable to negotiate: "no matching cipher found", is rejecting cbc |
1,485,634,653,000 |
The OpenSSH daemon has many "default" values for its settings. So looking at the sshd_config might not give someone the complete set of active settings.
How to display the full sshd configuration (for OpenSSH)?
|
The OpenSSH sshd command has an extended test switch which can be used to "Check the validity of the configuration file, output the effective configuration to stdout and then exit." (source sshd man page).
So the answer is (as root, or prefixing it with sudo):
sshd -T
(the settings are not in alphabetical order, one ... | Display full settings of sshd |
1,485,634,653,000 |
I have built a new Ubuntu server in AWS. Now for some reason my private key that works on other Ubuntu servers is not working her . The error in auth.log is
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
This only is an issue with Putty, if I try logging via a linux workstation no issues ... |
A simple solution.
Add this line in /etc/ssh/sshd_config.
PubkeyAcceptedAlgorithms +ssh-rsa
Afterwards, restart the sshd service to make the new settings come into effect.
$ sudo systemctl restart sshd
| SSH server gives "userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]" when connecting with Putty |
1,485,634,653,000 |
My understanding of the way ~/.ssh/config works is that each 'Host ' line takes effect for any host matching after that point in the config file.
I have a number of personal servers and work servers that I need to connect to. I'm trying to do something like the following:
# General Settings
ControlMaster auto
Contro... |
From the ssh_config manual:
Since the first obtained value for each parameter is used, more host-specific declarations should be given near the beginning of the file, and general defaults at the end.
So in your example, all hosts will use User harleypig and IdentityFile ~/.ssh/personal_id_rsa.
Think of Host directiv... | Multiple 'Host *' in ssh_config? |
1,485,634,653,000 |
So ssh has the option HostKeyAlgorithms. Sample usage:
ssh -o "HostKeyAlgorithms ssh-rsa" user@hostname
I'm trying to get the client to connect using the servers ecdsa key, but I can't find what the correct string is for that.
What command can I use to get a list of the available HostKeyAlgorithms?
|
ssh -Q key
Unless you have an ancient version of OpenSSH, in which case uhhhh source dive, or run ssh -v -v -v ... and see if what you want appears there.
| How do I list available host key algorithms for an SSH client? |
1,485,634,653,000 |
Today, after doing updates in Debian Stretch, it started displaying these warnings when restarting the ssh service with my current config:
/etc/ssh/sshd_config line 17: Deprecated option KeyRegenerationInterval
/etc/ssh/sshd_config line 18: Deprecated option ServerKeyBits
/etc/ssh/sshd_config line 29: Deprecated optio... |
In the current Stretch update, openssh version changed from 7.3 to 7.4, released on 2016-Dec-19.
As it can be inferred from the Release notes, and from @Jakuje comments, OpenSSH maintainers have removed the corresponding configuration options for good, as they are obsolete.
So the lines can be safely removed.
Also, ta... | Deprecated options when restarting openssh in Stretch |
1,485,634,653,000 |
I have the following entry in my .ssh/config file
Host AAA
User BBB
HostName CCC
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
The above allows me to multiplex multiple ssh sessions through the same ssh connection without having to type in the password every time I need a new session (as long as the ... |
The sshd daemon on the server is limiting the number of sessions per network connection. This is controlled by MaxSessions option in /etc/ssh/sshd_config. Also the MaxStartups option may need to be increased if you use a large number of sessions. (See man sshd_config for more details.) The option to modify MaxSessions... | Limits of SSH multiplexing |
1,485,634,653,000 |
Is there a way to convert existing pair of OpenSSH keys to the SSH2 (ssh.com format) pair of keys?
UPD: since there are some answers about ssh-keygen suddenly appeared, I'll explain where I came from (also it will be a nice answer on "what have you tried?").
$> diff --report-identical-files <(ssh-keygen -e -f ~/.ssh/... |
This tutorial titled: SSH: Convert OpenSSH to SSH2 and vise versa appears to offer what you're looking for.
Convert OpenSSH key to SSH2 key
Run the OpenSSH version of ssh-keygen on your OpenSSH public key to convert it into the format needed by SSH2 on the remote machine. This must be done on the system running OpenSS... | Convert OpenSSH private key into SSH2 private key |
1,485,634,653,000 |
I read about setting up ssh keys in Linux and have some questions. Correct me if I'm wrong…
Let's say host tr-lgto wants to connect to host tr-mdm using ssh. If we want to be sure that it's the real tr-mdm, we generate a pair of keys on tr-mdm and we add the public key to known_hosts on tr-lgto.
If tr-mdm wants to che... |
You're mixing up the authentication of the server machine to the client machine, and the authentication of the user to the server machine.
Server authentication
One of the first things that happens when the SSH connection is being established is that the server sends its public key to the client, and proves (thanks to... | SSH key-based authentication: known_hosts vs authorized_keys |
1,485,634,653,000 |
I am using Open SSH (OpenSSH_6.6.1p1, OpenSSL 1.0.1i 6 Aug 2014) in Windows 8.1.
X11 Forwarding does not appear to be working. The DISPLAY environment variable does not appear to be set.
For example, if I use BitVise or Putty to connect, and run env, I see:
[marko@vm:~]$ env
XDG_SESSION_ID=6
TERM=xterm
SHELL=/bin/bas... |
Have you set DISPLAY environment variable on the client? I'm not sure which shell you are using, but with Bourne shell derivative (like bash), please try:
export DISPLAY=127.0.0.1:0
ssh -X marko@vm
Or if you're using cmd.exe:
set DISPLAY=127.0.0.1:0
ssh -X marko@vm
Or if you're using powershell.exe:
$env:DISPLAY = ... | -X flag (X11 Forwarding) does not appear to work in Windows |
1,485,634,653,000 |
The OpenSSH client has a command line option for port forwarding, used like this:
ssh -L localport:server:serverport user@host
which will connect to host as user, and at the same time redirecting localport on the client to serverport on server (which can be host or anything reachable from host over the network).
Now ... |
From man 1 ssh:
ESCAPE CHARACTERS
When a pseudo-terminal has been requested, ssh supports a number of functions through the use of an escape character.
A single tilde character can be sent as ~~ or by following the tilde by a character other than those described below. The escape character must always follow a newlin... | Add port forwarding to a running SSH session |
1,485,634,653,000 |
One of my ec2 servers has stopped receiving ssh connections. The OS is Ubuntu server 8.04, and the ssh server is the standard openssh-server.
After months of uptime, I tried to connet to it today, and got the following message:
ssh_exchange_identification: Connection closed by remote host
Any idea what could have wen... |
Now that you once again have access, check the log to determine what, if any, clues there are as to why you were blocked.
tail -n300 /var/log/auth.log | grep ssh 1
The other thing to remember is that, if it happens again, you can run ssh in verbose mode with the -vvv option, which will return more detailed diagnostic ... | ssh server: reasons for sudden "Connection closed by remote host" |
1,485,634,653,000 |
I'm attempting to set up an SSH server on my local machine using OpenSSH.
When I try to SSH from a remote host into my local SSH server, the SSH server doesn't respond and the request times out. I'm pretty sure there's a really obvious fix for this that I'm simply overlooking.
Here's what happens when I try to SSH i... |
A Very Disappointing Self-Answer
Having set this problem aside for a day and come back to it, I was both relieved and perturbed (more perturbed than relieved) to find that everything was, mysteriously, working properly.
So, What Was the Issue?
No settings were changed or adjusted -- not on the router, not on the SSH ... | SSH Server not answering connection requests |
1,485,634,653,000 |
I'm using openssh on both client and server. I know I can run ssh -L or ssh -R to setup some port redirections over ssh. However, since they are command-line parameters, such redirections must be written before the connection is opened.
Can I setup port redirections on-the-fly using the command-line ssh client?
When I... |
If you're using the SSH command line, and you haven't switched the escape character feature off, then you can type ~C after a newline to open a mini-console on the ssh client. Then type -L port:host:port or -R port:host:port or -D port as you would on the command line to add a redirection, or -KR port to remove a redi... | How to setup port redirection after a ssh connection has been opened? |
1,485,634,653,000 |
So SSH has these files that configure settings for a specific user.
~/.ssh/authorized_keys
~/.ssh/config
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/known_hosts
I'd like to globalise some of these files, like config and known_hosts. So that other users ( including root ) could share the configured hosts.
What would be the... |
For ~/.ssh/config you can place relevant system-wide settings in /etc/ssh/ssh_config according to the man page:
ssh(1) obtains configuration data from the following sources in the following order:
command-line options
user's configuration file (~/.ssh/config)
system-wide configuration file (/etc/ssh/ssh_con... | making ssh hosts global to all the users on the computer |
1,485,634,653,000 |
I'm using openssh7.5p1 and gnupg 2.1.21 on arch linux (these are the default versions that come with arch). I would like to use gpg-agent as an ssh agent. I put the following in my ~/.gnupg/gpg-agent.conf:
pinentry-program /usr/bin/pinentry-qt
enable-ssh-support
Arch automatically starts a gpg-agent from systemd, s... |
The answer was apparently to run:
echo UPDATESTARTUPTTY | gpg-connect-agent
I have no idea why the pinentry program worked fine for other uses such as decrypting files, but didn't work for ssh-add.
While this now works, it also makes a copy of the ssh private key that doesn't show up under gpg -Kv, and furthermore do... | gpg-agent refuses SSH keys with ssh-add reporting "agent refused operation" |
1,485,634,653,000 |
I have server script that automatically pulls down and installs a github repository. As part of the script, I'm running ssh-keyscan -H github.com >> ~/.ssh/known_hosts as the git user to automatically accept github's RSA key prior to checking out the repo.
I have successfully used this same script in a local vagrant i... |
This does sound like a network problem to me.
The first thing that I would do is try telnetting to various SSH servers on port 22, something like the following:
$ telnet local-git-server 22
followed by:
$ telnet github.com 22
When you run this, you should see similar output to the following:
Escape character is '^]'.
... | ssh-keyscan has no output |
1,485,634,653,000 |
I’m having fun with OpenSSH, and I know the /etc/ssh directory is for the ssh daemon and the ~/.ssh directory is for a particular user.
Both directories contain private and public keys:
But what is the difference between those keys? I’m confused because the ones I use as a user is in my home directory, and what are t... |
/etc/ssh provides configuration for the system: default configuration for users (/etc/ssh/ssh_config), and configuration for the daemon (/etc/ssh/sshd_config). The various host files in /etc/ssh are used by the daemon: they contain the host keys, which are used to identify the server — in the same way that users are i... | What is the difference between /etc/ssh/ and ~/.ssh? |
1,485,634,653,000 |
~/.ssh/authorized_keys[2] contains the list of public keys.
Unfortunately, each public key does not specify the key strength ( number of bits ).
Is there a utility that can process this file line by line and output the key strength?
I checked man pages for ssh-keygen, but it looks like it would only work with private ... |
ssh-keygen can do the core of the work (generating a fingerprint from a public key), but it will not automatically process a list of multiple keys as is usually found in an authorized_keys file.
Here is a script that splits up the keys, feeds them to ssh-keygen and produces the table you want:
#!/bin/sh
# usage: auth... | Given keys in ~/.ssh/authorized_keys format, can you determine key strength easily? |
1,485,634,653,000 |
If I run something like this:
ssh -4 -f -N -T -R "/home/dude/lol.socket:192.168.4.44:4444" dude@someserver -p 22 -i privatekey -o "ExitOnForwardFailure yes" -o ConnectTimeout=5 -o ConnectionAttempts=3 -o ServerAliveInterval=15 -o
And then lets say the connection is closed or dies for whatever reason.. say the compute... |
TL;DR;
The solution is to set the value of StreamLocalBindUnlink to yes in sshd configuration on the server: sudo sh -c 'echo "StreamLocalBindUnlink yes" >> /etc/ssh/sshd_config'.
Long story
The reason this happens is because unix socket files are not automatically removed when the socket is closed. They need to be ma... | How to cleanup SSH reverse tunnel socket after connection closed? |
1,485,634,653,000 |
I would like using ssh tunneling options. For that purpose I use command:
ssh -L 1234:localhost:5678 host
however this logs me into the shell on remote host. Next I tried -f as:
ssh -f -L 8999:localhost:6006 host
but I get error Cannot fork into background without a command to execute.
How can I get only ssh tunne... |
Use the -N option
-N Do not execute a remote command. This is useful for just for-
warding ports (protocol version 2 only).
Example
ssh -fN -L 8999:localhost:6006 host
| Cannot tunnel over ssh without command/getting shell [duplicate] |
1,485,634,653,000 |
It seems like the following would work as expected, i.e., that the second rule, having a hostname that matches the first rule, would apply it.
Host *.hostname.com
User myuser
IdentityFile ~/.ssh/myidentity
Host blah
HostName complicated.hostname.com
However typing ssh blah only applies the second rule (and not th... |
From the ssh_config man page:
For each parameter, the first obtained value will be used. The configuration
files contain sections separated by “Host” specifications, and that section is
only applied for hosts that match one of the patterns given in the
specification. The matched host name is the one given ... | Why are rules not combining in an ssh config file? |
1,485,634,653,000 |
I'm trying to upgrade my ssh server from 2048-bit RSA keys to larger keys, as recommendations are to phase out 2048-bit keys soon.
I generated a new key, then added it to the sshd config, like this:
HostKey /etc/ssh/ssh_host_rsa_key (old 2k-bit key first)
HostKey /etc/ssh/ssh_host_rsa4096_key (new l... |
The Host Key rotation is supported since OpenSSH 6.8 (both client and server adds support in this version).
So the process should work like this:
Generate and add new keys with the option HostKey newkey (after the existing ones) to the /etc/ssh/sshd_config
Restart sshd
The clients have to set up UpdateHostKeys yes in... | How to roll over ssh host keys? |
1,485,634,653,000 |
Why do the "ssh_config(5)" manpages recommend that the ControlPath option should contain at least the %h, %p and %r placeholders in order to uniquely identify each shared connection?
I thought that multiple sessions should share the same socket with a connection to the same host. Wouldn't it make sense then to have a ... |
"I thought that multiple sessions should share the same socket with a connection to the same host."
They can. However, note that if you connect to a host using an existing connection via ControlPath, regardless of which user you intend to log in as, you will be logged in as the original user of the connection. Eg.,... | Why not simply use %h in OpenSSH ssh's ControlPath option? |
1,485,634,653,000 |
So, I have a bunch of machines I manage, where I've aliased each of them for ease of access.
This looks like this for each of them in the ssh client config:
Host MACHINE-1075 M1075 m1075 1075
User service
HostName 10.0.100.75
And also:
Match User service
IdentityFile ~/.ssh/service_user
Which allows me t... |
It's IMHO not entirely clear in man ssh_config, however the syntax for matching multiple conditions appears to be
Match keyword [pattern|pattern-list] keyword [pattern|pattern-list]
where patterns in pattern-list are comma-separated, but keyword pattern pairs are separated from one another by simple whitespace:
Match... | Matching both user and host simultaneously in SSH config |
1,485,634,653,000 |
I am using @GarethTheRed 's answer to this question to install fail2ban on a remote CentOS 7 server. I am able to complete all the steps up until tail -f /var/log/fail2ban.log, at which point I get different results than he gets in his answer.
Here are the results I am getting at this step:
[[email protected] ~]#... |
Try installing fail2ban from EPEL. It's packaged for CentOS 7 and you'll get updates as they are released. Installing the rpm form another repo may work (it did in this case) but is not the best way of doing things.
First of all, install the EPEL repository by issuing the following (as root):
yum install epel-release... | Installing fail2ban on CentOS 7 |
1,485,634,653,000 |
There is a Match group in the SSHD config:
cat /etc/ssh/sshd_config
...
Match Group FOOGROUP
ForceCommand /bin/customshell
...
There are many users on the machine that are in the "FOOGROUP".
My question: How can I exclude a given user that is in the "FOOGROUP" from the "Match Group"?
|
The Match operator can take multiple arguments, allowing very flexible rules. In this case, you could do something like this to achieve what you want.
Match Group FOOGROUP User !username
ForceCommand /bin/customshell
The ! negates the argument passed to the User criterion, so even if the user username is in the gro... | How to exclude from a "Match Group" in SSHD? |
1,485,634,653,000 |
I used to login to a remote machine( I have to root of this machine) using key. Both my local machine and remote machine is in f23. From last few days, I can't login to this machine using key. It is asking for password. Here is the ssh -vvv:
ssh -vvv aveta
OpenSSH_7.1p1, OpenSSL 1.0.2d-fips 9 Jul 2015
debug1: Reading ... |
There it is. Group has write access to ~rudra:
$ls -alF .ssh/ total 12K
drwx------. 2 rudra rudra 4.0K Oct 12 14:16 ./
drwxrwxr-x. 36 rudra rudra 4.0K Oct 12 14:30 ../
-rw-------. 1 rudra rudra 394 Oct 10 12:01 authorized_keys
Thus, sshd refuses to trust the files in ~rudra, and does not use ~rudra/.ssh/authorize... | Can't login to a remote machine with key |
1,485,634,653,000 |
I'm trying to test if ~/.ssh/id_rsa is actually password protected.
When you run ssh-keygen you can choose an empty password, and I'm trying to detect this.
Is that possible with a one-liner?
|
If you open the private key file in text editor you will be able to see ENCRYPTED in the second line of the RSA/DSA key file.
For example:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,373B504621779D53C72BADE597C531A0
| Test if SSH private key has password protection |
1,485,634,653,000 |
In my environment, actual .ssh directory exists on external device and links from it to ~/.ssh with a symbolic link. Using openssh as client is working without problem, but sshd does not allow to authentication with public key inside it.
Is there any method to use .ssh directory on external device?
journalctl -u sshd
... |
It is a permissions issue.
You need to check permissions for all directories above and including foobar's home, and also all directories above the target .ssh directory on your external device. Apart from foobar and the target .ssh directories, all others must be owned by root and not writeable by anyone else.
You ma... | OpenSSH refused .ssh directory with a symbolic link |
1,635,063,773,000 |
Since OpenSSH release 8.8 ssh-rsa is disabled in OpenSSH sshd:
$ ssh-audit 1.2.3.4
# algorithm recommendations (for OpenSSH 8.8)
...
(rec) +ssh-rsa -- key algorithm to append
...
Archlinux forum thread "Latest sshd not accepting key algorithms" recommends:
$ grep PubkeyA /etc/ssh/sshd_con... |
To permit using old RSA keys for OpenSSH 8.8+, add the following lines to your sshd_config:
HostKeyAlgorithms=ssh-rsa,[email protected]
PubkeyAcceptedAlgorithms=+ssh-rsa,[email protected]
Other distributions (then Arch on RPi) might support the more secure xmss keys, which are recommended for use by latest NIST pape... | How to enable ssh-rsa in sshd of OpenSSH 8.8? |
1,635,063,773,000 |
I'm running the below command, and monitoring the output file on the other system:
ssh $ip_address 'for n in 1 2 3 4 5; do sleep 10; echo $n >>/tmp/count; done'
If I kill the ssh command using ^C or by just killing the terminal I'm logged in on, I'd expect the remote command to terminate, too. This doesn't happen, th... |
uther's answer tells you to allocate a terminal but doesn't explain why. The reason is not specific to ssh, it is a matter of signal generation and propagation. I invite you to read What causes various signals to be sent? for more background.
On the remote host, there are two relevant processes:
an instance of the ss... | ssh command unexpectedly continues on other system after ssh terminates |
1,635,063,773,000 |
I have a Raspberry Pi (RPi) and I am making remote connections to it using ssh. I have managed to set up ssh correctly such that I can access the RPi both from a local area network and from the internet (using a specific port that I opened on my router).
Assuming an user name john and a RPi named raspi:
Inside LAN acc... |
Looking closer at your question, it appears you're using the same computer from both in- and outside of the LAN. I have revised my answer accordingly:
In your ~/.ssh/config, add:
Host raspi-wan
HostName 12.34.56.78
User john
Port 1234
Host raspi-lan
HostName 192.168.1.2
User john
Port 22
The... | SSH access from inside and outside a LAN using the same terminal command |
1,635,063,773,000 |
I am in a situation where several users are sharing the same user account on a remote machine. I have a "personal" directory where I wrote my own .zshrc file, and I would like to have a way to:
Start a ssh session in the remote machine with directives from my ssh config file
(e.g. ControlMaster auto)
This session run... |
The most obvious way to run a command remotely is to specify it on the ssh command line. The ssh command is always interpreted by the remote user's shell.
ssh [email protected] '. ~/.profile; command_that_needs_environment_variables'
ssh -t [email protected] '. ~/.profile; exec zsh'
Shared accounts are generally a ba... | ssh, start a specific shell, and run a command on the remote machine? |
1,635,063,773,000 |
Basically the entire question is in the headline: Does ssh send the password over the network? Presuming of course that login via username and password is used.
I'm asking because if ssh doesn't send the password over the network, a man in the middle can't get the user's password even if the user adds the alleged host... |
If you're using password authentication, then SSH sends the password over the network. The connection is encrypted, so eavesdroppers can't see the password. The connection is authenticated, provided that you don't click blindly through a “The authenticity of … can't be established” message, so your password won't be s... | Does ssh send the password over the network? |
1,635,063,773,000 |
In the example below what do the channel numbers correspond to? Which are on the server? Which are on the client?
$ ssh -L1570:127.0.0.1:8899 root@thehost
Password:
Last login: Fri Aug 9 13:08:44 2013 from theclientip
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
You have new mail.
... |
From the SSH Protocol documentation, regarding channels:
All terminal sessions, forwarded connections, etc., are channels.
Either side may open a channel. Multiple channels are multiplexed
into a single connection.
Channels are identified by numbers at each end. The number referring
to a channel may be differ... | What do the channel numbers in ssh error message refer to? |
1,635,063,773,000 |
My google search results little helpful so I asked here.
My Ubuntu server now has many duplicated entries in both files ~/.ssh/authorzied_keys and ~/.ssh/known_hosts
I wonder if there is a command/utility to remove those duplicated lines and list them once only?
|
The commandline utilities are called uniq and sort. You can simply pipe the file through them to get only unique entries:
sort ~/.ssh/authorized_keys | uniq > ~/.ssh/authorized_keys.uniq
and then replace the old file with the new one:
mv ~/.ssh/authorized_keys{.uniq,}
The ~/.ssh/known_hosts are handled by ssh itself... | How to clear duplicated entries in SSH known_hosts and authorized_keys files? |
1,635,063,773,000 |
Quick version:
ssh & scp work from my desktop and laptop computers. From termux on my android phone, ssh works but scp does not. In this case, I get an error about "Connection closed".
Expanded version
Originally, when I had asked this question, I had been encountering it while running scp from termux on my android p... |
Quick version (TL;DR)
Update: For those that just want a quick-and-dirty with minimal reading.
Know:
This actually had nothing to do with Termux - it affects any Linux using OpenSSH 8.8+. I also ran into it on Fedora 35 with OpenSSH 8.7p1
While sftp will work in a pinch, it handles copying of symlinks differently tha... | ssh working on all devices but scp from some devices gives "Connection closed" error |
1,635,063,773,000 |
man ssh says:
SSH_ASKPASS
If ssh needs a passphrase, it will read the passphrase from the
current terminal if it was run from a terminal. If ssh does not
have a terminal associated with it but DISPLAY and SSH_ASKPASS
are set, it will execute the program specified by SSH_ASKPASS
and open an X11 wi... |
This will be a bit more complicated, but combination of several pieces will make it working:
Explanation
To force ssh to use $SSH_ASKPASS program, you can't allow ssh to see the real tty. It is just condition. This can be done by using setsid and using -n switch to ssh.
This case would initiate connection, but you wo... | Can I get SSH to use an askpass program even if it was run from a terminal? |
1,635,063,773,000 |
The RFC:
Uniform Resource Identifier (URI) Scheme for Secure File Transfer
Protocol (SFTP) and Secure Shell (SSH)
presents the SSH URI as:
ssh://[<user>[;fingerprint=<host-key fingerprint>]@]<host>[:<port>]
Are there any known reasons why the OpenSSH ssh command doesn't follow this standard with the hostname option... |
ssh predates the more general URI format (1998) by several years (1995 IIRC).
| Why doesn't the ssh command follow RFC on URI? |
1,635,063,773,000 |
In Ubuntu GNU/Linux 12.04, I have a user johndoe that is part of an sftponly group, set up to sftp to a chroot jail using
Subsystem sftp internal-sftp
Match Group sftponly
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
at the end of /etc/ssh/ssh_config. All components of ... |
A typo on my part was the cause of the unreasonable behavior I was experiencing above. It is /etc/ssh/sshd_config (corresponding to the ssh daemon) that must be edited, not /etc/ssh/ssh_config (corresponding to the ssh client). I leave this question here in case it may help someone else.
| How to prevent "Last Login:" message from showing up when using sftp? |
1,635,063,773,000 |
I'm running an ubuntu image in a docker container, with my .ssh directory mounted from my native MacOs environment.
My .ssh/config file contains
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519_common
This works fine on a mac, but AddKeysToAgent and UseKeychain are not valid for linux, a... |
You can use the Match keyword in the ssh config file to restrict a portion of the configuration to only apply under certain conditions. For the excerpt in the question, something like the following should work:
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519_common
Match exec "uname -s | grep Darwin... | Can I ignore errors in my ssh config? |
1,635,063,773,000 |
A vulnerability scan showed that in a Debian 10 system, insecure MAC algorithms are in use: [email protected],[email protected],[email protected],hmac-sha1
When I do ssh -Q mac, I get the following results:
hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
hmac-md5
hmac-md5-96
[email protected]
[email protected]
[ema... |
The list of supported MAC algorithms is determined by the MACs option, both in ssh_config and in sshd_config. If it's absent, the default is used. If you want to change the value from the default, either edit the existing entry or add one if it isn't present. For example:
MACs hmac-sha2-256,hmac-sha2-512,[email protec... | How to disable weak HMAC Algorithms? Not found in ssh_config or sshd_config file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.