A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label login. Show all posts
Showing posts with label login. Show all posts

Ubuntu Linux setup basics

For username "foo":

$ adduser foo

$ passwd foo

$ sudo usermod -aG sudo foo

mkdir -p /home/foo/.ssh

$ cat the_public_key.pem >> /home/foo/.ssh/authorized_keys

chown -R foo:foo /home/foo/.ssh

$ chmod 700 /home/foo/.ssh

$ chmod 600 /home/foo/.ssh/authorized_keys
Disable default account:
$ usermod -s /usr/sbin/nologin default_username

Notes:
  • Not useradd.
  • Even when logging in with just SSH key, user must have a password. It will only be used for sudo commands.

Hack your own MySQL to log in as root

$> sudo service mysql stop

$> mysqld --skip-grant-tables

$> mysql

mysql> FLUSH PRIVILEGES;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

mysql> SELECT host, user, plugin FROM mysql.user;

(source)

Automate an FTP script

in the ftp script put.pl:
#!/bin/bash
HOST="example.com"
HOMEDIR="/"
ftp -i $HOST <<-EOF
passive
cd $HOMEDIR
put $1
quit
EOF
echo "I put the file "$1

in ~/.netrc:

machine example.com
    login [username]
    password [password]

to run:
put.pl [filename]

Add a password to a MySQL login

Many applications require there to be a password.

SELECT host, user FROM mysql.user;

SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');

Beware of backslashes in login strings

using URI to parse an ftp connection string like:
ftp://domain\user:pass@host/path
...can lead to problems.
The backslash is not a legal URI character, so $uri->user may bring back just the domain!