User login

ssh

Set login name to use for SSH per host

As a completely hypothetical example, suppose you boneheadly thought it would be nice to standardize your local login name to something different than on some existing servers.

You want standard scripts that assume current username to work— you wrote them to share, after all. So how to make this work?

Something like this in your ~/.ssh/config file (create and chmod 600 if it doesn't exist already) will work:

Host agaric-test
Hostname test.example.org
User bmelanco

Troubleshooting ssh connections problem

Micky found this which was key to debugging our connection problem— one way to watch what is happening with the SSH connection attempt is by opening a port just for this use on the server:

sudo /usr/sbin/sshd -d -p 2222

Then from the client:

ssh -vv -p 2222 example.com

Per http://www.unixlore.net/articles/troubleshooting-ssh-connections.html

Passwordless SSH (using Public Keys and Agent Forwarding)

Part I: Private and Public Keys

SSH public key authentication requires the user to create a public/private key pair on her machine. It's easy:

ssh-keygen

A key pair will be generated (it is ok to hit enter every time you are prompted by the key generator) and stored in ~/.ssh. The default names are id_rsa/id_rsa.pub and id_dsa/id_dsa.pub depending on the encryption algorithm. For each device used to connect to remote machines via ssh this must be repeated. It's not a good idea to spread the private key.

Update a Debian user's password and passkey and grant sudo access

For a user named agaric:

sudo passwd agaric
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

From a different server with working id_dsa public key that had been cat'd into authorized_keys:

scp authorized_keys ben@example.org:~

Then back on the server to which we're updating this user, from your own home directory to which you just uploaded the authorized keys file.
sudo mv authorized_keys /home/agaric/.ssh

Moving a MySQL Database by Command Line Interface

mysqldump -u root -p internetbar_live > internetbar_backup.sql

(should gzip here)

This command compresses the file database.sql and replaces it -- deletes it -- with the compressed .gz file database.sql.gz

gzip database.sql

scp ben@66.135.41.18:~/internetbar_backup.sql internetbar_backup.sql

On the other end if you compressed, uncompress:

gunzip database.sql.gz

Note: tar is for making an archive of multiple files.

Server access via passkey, setting up sudo, loosening control temporarily

in

For the steps Agaric uses, see Create a new user on Agaric's test server with May First People Link.

If the user isn't on the server yet:

sudo adduser veronica

Transfering files directly between two servers: setting up ssh keys

Search words: upload ssh

Two servers with ssh keys instead of password logins won't let you copy a file directly between servers until you set this up.

(These instructions may be incomplete.)

On the new server:

cp /home/dan/.ssh/id_rsa.pub /home/dan/

If there is no file like that or .pub, make it first: ssh-keygen -t dsa

From your computer:

Search words: upload ssh Two servers with ssh keys instead of password logins won't let you copy a file directly between servers until you set this up. (These instructions may be incomplete.) On the new server: cp /home/dan/.ssh/id_rsa.pub /home/dan/
Syndicate content