I'd like to write an automation script that sets PasswordAuthentication no
in /etc/ssh/sshd_config
. However, I wan't to guard against locking myself out in case I run the script while being logged in via SSH and password authentication. Is there a way to determine the authentication method of my SSH connection when I'm already logged in?
chiborg's questions
I have a network with different OSs (Windows, macOS, iOS, Linux) and browsers. I would like to centrally manage the list of trusted Certificate Authorities on all clients/browsers. And I'd like to avoid having to manage the list CA manually on each client. Is there any OS-agnostic way to distribute the list of valid CAs to the clients, either through service discovery (have a service that announces "Hey, get your CA list here") or by a OS setting that triggers the clients to pull the list? Windows Active Directory Certificate Services seems to do this, but I'd rather use an Open Source solution.
I have an Nginx configuration that is for a new PHP application that has the same functionality as another legacy PHP application, but different URLs.
I want to preserve the paths of the old application, replacing the /foo
path prefix with /page
and replacing the special path /foo/bar
with /page/otherBar
:
# legacy support
location ~ ^/foo/bar {
rewrite /foo/bar /page/otherBar$1 last;
}
# How to rewrite all other pages starting with "/foo" ?
# END legacy support
location / {
# try to serve file directly, fallback to front controller
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
proxy_read_timeout 300;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/www/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
This approach does not work, because $request_uri
, which gets passed to REQUEST_URI
in the fastcgi_params
include file, still contains /foo/bar
.
I've tried setting REQUEST_URI
to $fastcgi_path_info
but that fails for all non-rewritten URLs as it is empty then. $uri
also does not work because it just contains /index.php?
Is there any variable for the third location config that contains the rewritten path?
I have a playbook with two plays, one local and one remote. I have two inventories, one for test and one for production. Each inventory defines a variable for the remote group, but I would like to use the variable in the local play without using delegation. Is that possbile and how would I do that?
Example Playbook:
- hosts: local
tasks:
# ... lots of local build steps here
- command: tar -czf {{ archive_name }} /build_dir
- hosts: remote
tasks:
- unarchive: src={{ archive_name }} dest=/deploy_dir
Test inventory:
[local]
127.0.0.1
[remote]
test.example.com
[remote:vars]
archive_name=/tmp/test-build.tgz
Production Inventory:
[local]
127.0.0.1
[remote]
www.example.com
[remote:vars]
archive_name=/tmp/production-build.tgz
This example fails because {{ archive_name }}
is not defined for the local
group.
A solution to this would have the following constraints:
- I can't put it into a file in
group_vars
because I have different inventories with the same group names. - I'd rather not delegate the build process tasks instead of using a separate play.
- I would like to keep the variable in the inventory file and not dynamically load other files.
The only option I see at the moment is to define {{ archive_name }}
again for the local
group, but that's error-prone.
I've created a virtual machine with Vagrant and some provisioning scripts. Now I want to hand out copies of the fully provisioned machine to participants at a workshop. This workshop will be mainly about the software running in the VM and not so much about Vagrant, so installing Vagrant on the participant's machines is out of the question. Is there an easy way to create an OVA file from the VM I created with Vagrant?
The "hard way" I'm planning to do is writing a script that uses various vboxmanage
commands to
- clone the VM created by Vagrant
- remove unneccessary shared folders (only used for provisioning).
- export the clone to an OVA file
But maybe there is a better way?
On my Linux development system I use fakemail to write mails to a directory instead of sending them. The mail files contain the headers and the text of the mail as quoted-printable, text/plain in UTF-8. How can I read a single mail file and "decode" the quoted-printable so line breaks and special chars show up correctly?
Here is an example of a German mail file with line breaks and special chars:
Message-ID: <[email protected]>
Date: Fri, 07 Oct 2011 10:53:26 +0200
Subject: Registrierung
From: [email protected]
To: [email protected]
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hallo,
Sie haben sich auf Meinserver.de als Benutzer regist=
riert. Um Ihre
Registrierung abzuschlie=C3=9Fen, klicken Sie auf folg=
enden Link:
http://meinserver.de/benutzer/bestaetigen/3lk6lp=
ga1kcgcg484kc8ksg
I want the special chars to be replaced with their proper counterparts and the line breaks inserted by the quoted-printable encoding (the ones with a "=" at the end) removed.
I have a python script as a cron job that is called like this
/path/to/python /path/to/myscript myparam
When an error occurs in the script, the cronjob silently fails. When I run the same command from the command line, I get a stack trace. How can I bring my script to output the stack trace (or write it to a file) when running as a cron job? I have already set the MAILTO
variable. I have also tried putting
/path/to/python /path/to/myscript myparam 2>&1 >> /path/to/logfile
in the crontab but logfile remains empty.
Update: The call without output redirection works now. It was not an issue with the python script, but a wrong separator in the MAILTO crontab setting. Remember: Use commas and don't put spaces after the commas!
I have an issue with the Vim color schemes: The background color does not fill the whole screen. For example, in the "blue" color scheme the whole screen should turn blue. Instead, the blue background only extends to the end of each line. Is this a setting in the console I'm missing or is this an issue with my vim default settings?
I'm only having this issue with Ubuntu 10.10. echo $TERM
outputs xterm-color
.
[Update]: To eliminate error sources my minimal ~/.vimrc looks like this:
filetype plugin on
colorscheme blue
syntax on
/etc/vim/vimrc
contains the unchanged defaults of Ubuntu
You know the situation: You are halfway through typing a long command (for example a commit message) and realize that you have forgotten to execute some prerequisite command that can not be added with &&
. Normally when that happens to me, I select what I have typed with the mouse, copy it to the clipboard, press Ctrl-U to clear the line, run my prerequisite command and paste form the clipboard. But maybe there is a better way, preferably without needing to use the mouse? I'm looking for solutions for bash and/or zsh.